Re: [PATCH] staging: dgnc: Fix lines longer than 80 characters

2016-12-05 Thread Dan Carpenter
On Fri, Dec 02, 2016 at 08:13:49PM +0100, Fernando Apesteguia wrote:
> For the first lines of the patch, I opted to create a small function
> instead of breaking the the line in a weird way.

These first ones are the nice.

> @@ -2511,13 +2516,15 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
> unsigned int cmd,
>   if (ch->ch_tun.un_flags & (UN_LOW | UN_EMPTY)) {
>   ch->ch_tun.un_flags &=
>   ~(UN_LOW | UN_EMPTY);
> - 
> wake_up_interruptible(&ch->ch_tun.un_flags_wait);
> + wake_up_interruptible(&ch->ch_tun
> + .un_flags_wait);


Ugh...  No.  Don't do this.  Just let it go over 80 characters.  Ignore
the warning.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: Fix lines longer than 80 characters

2016-12-04 Thread Fernando Apesteguia
On Sat, Dec 03, 2016 at 11:11:23AM +0100, Greg KH wrote:
> On Sat, Dec 03, 2016 at 10:56:54AM +0100, Fernando Apesteguia wrote:
> > On Sat, Dec 03, 2016 at 09:51:13AM +0100, Greg KH wrote:
> > > On Fri, Dec 02, 2016 at 08:13:49PM +0100, Fernando Apesteguia wrote:
> > > > For the first lines of the patch, I opted to create a small function
> > > > instead of breaking the the line in a weird way.
> > > > 
> > > > The other changes are simple ones.
> > > > 
> > > > Signed-off-by: Fernando Apesteguia 
> > > > ---
> > > >  drivers/staging/dgnc/dgnc_tty.c | 42 
> > > > +
> > > >  1 file changed, 26 insertions(+), 16 deletions(-)
> > > > 
> > > > diff --git a/drivers/staging/dgnc/dgnc_tty.c 
> > > > b/drivers/staging/dgnc/dgnc_tty.c
> > > > index af4bc86..835d448 100644
> > > > --- a/drivers/staging/dgnc/dgnc_tty.c
> > > > +++ b/drivers/staging/dgnc/dgnc_tty.c
> > > > @@ -102,6 +102,7 @@ static int dgnc_tty_write(struct tty_struct *tty, 
> > > > const unsigned char *buf,
> > > >  static void dgnc_tty_set_termios(struct tty_struct *tty,
> > > >  struct ktermios *old_termios);
> > > >  static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);
> > > > +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned 
> > > > char line);
> > > >  
> > > >  static const struct tty_operations dgnc_tty_ops = {
> > > > .open = dgnc_tty_open,
> > > > @@ -786,6 +787,12 @@ void dgnc_check_queue_flow_control(struct 
> > > > channel_t *ch)
> > > > }
> > > >  }
> > > >  
> > > > +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned 
> > > > char line)
> > > > +{
> > > > +   ch->ch_mostat &= ~(line);
> > > > +   ch->ch_bd->bd_ops->assert_modem_signals(ch);
> > > > +}
> > > 
> > > Your name here is odd, it is named because of what it does to the coding
> > > style, not to the logic of what is happening in the function itself,
> > > making it very confusing.
> > 
> > It was a bad choice indeed :) but I didn't mean anything about the coding
> > style but about what the fuction does. It was meant to be read as:
> > "keep_signal_low" since the function puts (RTS/DTR) UART "line" to low.
> > 
> > Would "keep_signal_low" be clear and representative of what the function 
> > does?
> 
> It's not "keep", it is "change", right?  I don't remember the context
> now, sorry, you could be correct...

Yes, I think "change" or even "set" would be more appropriate. I'll rework the
patch and send it again.

Thanks.

> 
> 
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: Fix lines longer than 80 characters

2016-12-03 Thread Greg KH
On Sat, Dec 03, 2016 at 10:56:54AM +0100, Fernando Apesteguia wrote:
> On Sat, Dec 03, 2016 at 09:51:13AM +0100, Greg KH wrote:
> > On Fri, Dec 02, 2016 at 08:13:49PM +0100, Fernando Apesteguia wrote:
> > > For the first lines of the patch, I opted to create a small function
> > > instead of breaking the the line in a weird way.
> > > 
> > > The other changes are simple ones.
> > > 
> > > Signed-off-by: Fernando Apesteguia 
> > > ---
> > >  drivers/staging/dgnc/dgnc_tty.c | 42 
> > > +
> > >  1 file changed, 26 insertions(+), 16 deletions(-)
> > > 
> > > diff --git a/drivers/staging/dgnc/dgnc_tty.c 
> > > b/drivers/staging/dgnc/dgnc_tty.c
> > > index af4bc86..835d448 100644
> > > --- a/drivers/staging/dgnc/dgnc_tty.c
> > > +++ b/drivers/staging/dgnc/dgnc_tty.c
> > > @@ -102,6 +102,7 @@ static int dgnc_tty_write(struct tty_struct *tty, 
> > > const unsigned char *buf,
> > >  static void dgnc_tty_set_termios(struct tty_struct *tty,
> > >struct ktermios *old_termios);
> > >  static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);
> > > +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char 
> > > line);
> > >  
> > >  static const struct tty_operations dgnc_tty_ops = {
> > >   .open = dgnc_tty_open,
> > > @@ -786,6 +787,12 @@ void dgnc_check_queue_flow_control(struct channel_t 
> > > *ch)
> > >   }
> > >  }
> > >  
> > > +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char 
> > > line)
> > > +{
> > > + ch->ch_mostat &= ~(line);
> > > + ch->ch_bd->bd_ops->assert_modem_signals(ch);
> > > +}
> > 
> > Your name here is odd, it is named because of what it does to the coding
> > style, not to the logic of what is happening in the function itself,
> > making it very confusing.
> 
> It was a bad choice indeed :) but I didn't mean anything about the coding
> style but about what the fuction does. It was meant to be read as:
> "keep_signal_low" since the function puts (RTS/DTR) UART "line" to low.
> 
> Would "keep_signal_low" be clear and representative of what the function does?

It's not "keep", it is "change", right?  I don't remember the context
now, sorry, you could be correct...


greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: Fix lines longer than 80 characters

2016-12-03 Thread Fernando Apesteguia
On Sat, Dec 03, 2016 at 09:51:13AM +0100, Greg KH wrote:
> On Fri, Dec 02, 2016 at 08:13:49PM +0100, Fernando Apesteguia wrote:
> > For the first lines of the patch, I opted to create a small function
> > instead of breaking the the line in a weird way.
> > 
> > The other changes are simple ones.
> > 
> > Signed-off-by: Fernando Apesteguia 
> > ---
> >  drivers/staging/dgnc/dgnc_tty.c | 42 
> > +
> >  1 file changed, 26 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/staging/dgnc/dgnc_tty.c 
> > b/drivers/staging/dgnc/dgnc_tty.c
> > index af4bc86..835d448 100644
> > --- a/drivers/staging/dgnc/dgnc_tty.c
> > +++ b/drivers/staging/dgnc/dgnc_tty.c
> > @@ -102,6 +102,7 @@ static int dgnc_tty_write(struct tty_struct *tty, const 
> > unsigned char *buf,
> >  static void dgnc_tty_set_termios(struct tty_struct *tty,
> >  struct ktermios *old_termios);
> >  static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);
> > +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char 
> > line);
> >  
> >  static const struct tty_operations dgnc_tty_ops = {
> > .open = dgnc_tty_open,
> > @@ -786,6 +787,12 @@ void dgnc_check_queue_flow_control(struct channel_t 
> > *ch)
> > }
> >  }
> >  
> > +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char 
> > line)
> > +{
> > +   ch->ch_mostat &= ~(line);
> > +   ch->ch_bd->bd_ops->assert_modem_signals(ch);
> > +}
> 
> Your name here is odd, it is named because of what it does to the coding
> style, not to the logic of what is happening in the function itself,
> making it very confusing.

It was a bad choice indeed :) but I didn't mean anything about the coding
style but about what the fuction does. It was meant to be read as:
"keep_signal_low" since the function puts (RTS/DTR) UART "line" to low.

Would "keep_signal_low" be clear and representative of what the function does?


> 
> Yes, naming is hard, one of the hardest things in programming.

Indeed!

Thanks!

> 
> thanks,
> 
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: dgnc: Fix lines longer than 80 characters

2016-12-03 Thread Greg KH
On Fri, Dec 02, 2016 at 08:13:49PM +0100, Fernando Apesteguia wrote:
> For the first lines of the patch, I opted to create a small function
> instead of breaking the the line in a weird way.
> 
> The other changes are simple ones.
> 
> Signed-off-by: Fernando Apesteguia 
> ---
>  drivers/staging/dgnc/dgnc_tty.c | 42 
> +
>  1 file changed, 26 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
> index af4bc86..835d448 100644
> --- a/drivers/staging/dgnc/dgnc_tty.c
> +++ b/drivers/staging/dgnc/dgnc_tty.c
> @@ -102,6 +102,7 @@ static int dgnc_tty_write(struct tty_struct *tty, const 
> unsigned char *buf,
>  static void dgnc_tty_set_termios(struct tty_struct *tty,
>struct ktermios *old_termios);
>  static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);
> +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char 
> line);
>  
>  static const struct tty_operations dgnc_tty_ops = {
>   .open = dgnc_tty_open,
> @@ -786,6 +787,12 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
>   }
>  }
>  
> +static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char 
> line)
> +{
> + ch->ch_mostat &= ~(line);
> + ch->ch_bd->bd_ops->assert_modem_signals(ch);
> +}

Your name here is odd, it is named because of what it does to the coding
style, not to the logic of what is happening in the function itself,
making it very confusing.

Yes, naming is hard, one of the hardest things in programming.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: dgnc: Fix lines longer than 80 characters

2016-12-02 Thread Fernando Apesteguia
For the first lines of the patch, I opted to create a small function
instead of breaking the the line in a weird way.

The other changes are simple ones.

Signed-off-by: Fernando Apesteguia 
---
 drivers/staging/dgnc/dgnc_tty.c | 42 +
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index af4bc86..835d448 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -102,6 +102,7 @@ static int dgnc_tty_write(struct tty_struct *tty, const 
unsigned char *buf,
 static void dgnc_tty_set_termios(struct tty_struct *tty,
 struct ktermios *old_termios);
 static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);
+static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char line);
 
 static const struct tty_operations dgnc_tty_ops = {
.open = dgnc_tty_open,
@@ -786,6 +787,12 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
}
 }
 
+static void dgnc_keep_line_low(struct channel_t *ch, const unsigned char line)
+{
+   ch->ch_mostat &= ~(line);
+   ch->ch_bd->bd_ops->assert_modem_signals(ch);
+}
+
 void dgnc_wakeup_writes(struct channel_t *ch)
 {
int qlen = 0;
@@ -823,19 +830,15 @@ void dgnc_wakeup_writes(struct channel_t *ch)
 * If RTS Toggle mode is on, whenever
 * the queue and UART is empty, keep RTS low.
 */
-   if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) {
-   ch->ch_mostat &= ~(UART_MCR_RTS);
-   
ch->ch_bd->bd_ops->assert_modem_signals(ch);
-   }
+   if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)
+   dgnc_keep_line_low(ch, UART_MCR_RTS);
 
/*
 * If DTR Toggle mode is on, whenever
 * the queue and UART is empty, keep DTR low.
 */
-   if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) {
-   ch->ch_mostat &= ~(UART_MCR_DTR);
-   
ch->ch_bd->bd_ops->assert_modem_signals(ch);
-   }
+   if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)
+   dgnc_keep_line_low(ch, UART_MCR_DTR);
}
}
 
@@ -969,8 +972,9 @@ static int dgnc_tty_open(struct tty_struct *tty, struct 
file *file)
 * touched safely, the close routine will signal the
 * ch_flags_wait to wake us back up.
 */
-   rc = wait_event_interruptible(ch->ch_flags_wait, (((ch->ch_tun.un_flags 
|
- ch->ch_pun.un_flags) & UN_CLOSING) == 0));
+   rc = wait_event_interruptible(ch->ch_flags_wait,
+   (((ch->ch_tun.un_flags |
+  ch->ch_pun.un_flags) & UN_CLOSING) == 0));
 
/* If ret is non-zero, user ctrl-c'ed us */
if (rc)
@@ -1188,11 +1192,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty,
 */
if (sleep_on_un_flags)
retval = wait_event_interruptible
-   (un->un_flags_wait, (old_flags != 
(ch->ch_tun.un_flags |
-  
ch->ch_pun.un_flags)));
+   (un->un_flags_wait,
+(old_flags != (ch->ch_tun.un_flags |
+   ch->ch_pun.un_flags)));
else
retval = wait_event_interruptible(ch->ch_flags_wait,
- (old_flags != 
ch->ch_flags));
+   (old_flags != ch->ch_flags));
 
/*
 * We got woken up for some reason.
@@ -2511,13 +2516,15 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
if (ch->ch_tun.un_flags & (UN_LOW | UN_EMPTY)) {
ch->ch_tun.un_flags &=
~(UN_LOW | UN_EMPTY);
-   
wake_up_interruptible(&ch->ch_tun.un_flags_wait);
+   wake_up_interruptible(&ch->ch_tun
+   .un_flags_wait);
}
 
if (ch->ch_pun.un_flags & (UN_LOW | UN_EMPTY)) {
ch->ch_pun.un_flags &=
~(UN_LOW | UN_EMPTY);

[PATCH] staging: dgnc: Fix lines longer than 80 characters

2016-09-28 Thread Fernando Apesteguia
All the chunks of the patch apply to comments save the first one.

Signed-off-by: Fernando Apesteguia 
---
 drivers/staging/dgnc/dgnc_neo.c | 67 -
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index e794056..5becb37 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -449,7 +449,8 @@ static inline void neo_parse_isr(struct dgnc_board *brd, 
uint port)
   flags);
}
} else if (cause == UART_17158_XOFF_DETECT) {
-   if (!(brd->channels[port]->ch_flags & CH_STOP)) 
{
+   if (!(brd->channels[port]->ch_flags &
+ CH_STOP)) {
spin_lock_irqsave(&ch->ch_lock,
  flags);
ch->ch_flags |= CH_STOP;
@@ -554,7 +555,8 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, 
uint port)
 * Rx Oruns. Exar says that an orun will NOT corrupt
 * the FIFO. It will just replace the holding register
 * with this new data byte. So basically just ignore this.
-* Probably we should eventually have an orun stat in our 
driver...
+* Probably we should eventually have an orun stat in our
+* driver...
 */
ch->ch_err_overrun++;
}
@@ -949,14 +951,18 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
 
/*
 * If 0, no interrupts pending.
-* This can happen if the IRQ is shared among a couple Neo/Classic 
boards.
+* This can happen if the IRQ is shared among a couple Neo/Classic
+* boards.
 */
if (!uart_poll) {
spin_unlock_irqrestore(&brd->bd_intr_lock, flags);
return IRQ_NONE;
}
 
-   /* At this point, we have at least SOMETHING to service, dig further... 
*/
+   /*
+* At this point, we have at least SOMETHING to service, dig
+* further...
+*/
 
/* Loop on each port */
while ((uart_poll & 0xff) != 0) {
@@ -980,7 +986,10 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
ch = brd->channels[port];
neo_copy_data_from_uart_to_queue(ch);
 
-   /* Call our tty layer to enforce queue flow control if 
needed. */
+   /*
+* Call our tty layer to enforce queue flow control if
+* needed.
+*/
spin_lock_irqsave(&ch->ch_lock, flags2);
dgnc_check_queue_flow_control(ch);
spin_unlock_irqrestore(&ch->ch_lock, flags2);
@@ -996,16 +1005,18 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
 
case UART_17158_TXRDY:
/*
-* TXRDY interrupt clears after reading ISR register 
for the UART channel.
+* TXRDY interrupt clears after reading ISR register
+* for the UART channel.
 */
 
/*
 * Yes, this is odd...
 * Why would I check EVERY possibility of type of
 * interrupt, when we know its TXRDY???
-* Becuz for some reason, even tho we got triggered for 
TXRDY,
-* it seems to be occasionally wrong. Instead of TX, 
which
-* it should be, I was getting things like RXDY too. 
Weird.
+* Becuz for some reason, even tho we got triggered for
+* TXRDY, it seems to be occasionally wrong. Instead of
+* TX, which it should be, I was getting things like
+* RXDY too. Weird.
 */
neo_parse_isr(brd, port);
break;
@@ -1020,8 +1031,8 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
default:
/*
 * The UART triggered us with a bogus interrupt type.
-* It appears the Exar chip, when REALLY bogged down, 
will throw
-* these once and awhile.
+* It appears the Exar chip, when REALLY bogged down,
+* will throw these once and awhile.
 * Its harmless, just ignore it and move on.
 */
break;
@@ -1239,7 +1250,8 @@ static void neo_copy_data_from_uart_to_queue(struct 
channel_t *ch)