Skip to contentSkip to conversation

staging: dgnc: Fix lines longer than 80 characters

PATCH Superseded Fernando Apesteguia 3 participants 6 messages Dec 2, 2016 – Dec 5, 2016 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: dgnc: Fix lines longer than 80 characters

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.

---
 drivers/staging/dgnc/dgnc_tty.c | 42 +++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +26 -16
index af4bc86..835d448 100644
@@ -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);
-					wake_up_interruptible(&ch->ch_pun.un_flags_wait);
+					wake_up_interruptible(&ch->ch_pun
+							.un_flags_wait);
 				}
 			}
 		}
@@ -2737,7 +2744,10 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 		buf.rxbuf = (ch->ch_r_head - ch->ch_r_tail) & RQUEUEMASK;
 		buf.txbuf = (ch->ch_w_head - ch->ch_w_tail) & WQUEUEMASK;
 
-		/* Is the UART empty? Add that value to whats in our TX queue. */
+		/*
+		 * Is the UART empty?
+		 * Add that value to whats in our TX queue.
+		 */
 
 		count = buf.txbuf + ch_bd_ops->get_uart_bytes_left(ch);
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 23 lines · 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.

---
 drivers/staging/dgnc/dgnc_tty.c | 42 +++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +1 -0
index af4bc86..835d448 100644
@@ -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,

drivers/staging/dgnc/dgnc_tty.c void dgnc_check_queue_flow_control(struct channel_t *ch) · line 794

Quoted 8 lines
drivers/staging/dgnc/dgnc_tty.c +5 -0
@@ -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

#2 lore raw
Quoted 27 lines · Greg KH
Quoted 26 lines · 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.

---
 drivers/staging/dgnc/dgnc_tty.c | 42 +++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +1 -0
index af4bc86..835d448 100644
@@ -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)
 	}
 }
 
Quoted 9 lines

drivers/staging/dgnc/dgnc_tty.c void dgnc_check_queue_flow_control(struct channel_t *ch) · line 794

Quoted 5 lines
drivers/staging/dgnc/dgnc_tty.c +5 -0
+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?

Quoted 2 lines

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

Indeed!

Thanks!

Quoted 4 lines

thanks,

greg k-h

maintainer
#3 lore raw
Quoted 38 lines · Fernando Apesteguia
Quoted 27 lines · Greg KH
Quoted 26 lines · 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.

---
 drivers/staging/dgnc/dgnc_tty.c | 42 +++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +1 -0
index af4bc86..835d448 100644
@@ -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)
 	}
 }
 
Quoted 9 lines

drivers/staging/dgnc/dgnc_tty.c void dgnc_check_queue_flow_control(struct channel_t *ch) · line 794

Quoted 5 lines
drivers/staging/dgnc/dgnc_tty.c +5 -0
+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.

Quoted 5 lines

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

#4 lore raw
Quoted 39 lines · Greg KH
Quoted 38 lines · Fernando Apesteguia
Quoted 36 lines · Greg KH
Quoted 23 lines · 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.

---
 drivers/staging/dgnc/dgnc_tty.c | 42 +++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +1 -0
index af4bc86..835d448 100644
@@ -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,

drivers/staging/dgnc/dgnc_tty.c void dgnc_check_queue_flow_control(struct channel_t *ch) · line 794

Quoted 8 lines
drivers/staging/dgnc/dgnc_tty.c +5 -0
@@ -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.

Quoted 8 lines
Quoted 5 lines

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.

Quoted 3 lines

greg k-h

#5 lore raw
In reply to Fernando Apesteguia
Quoted 2 lines · 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.

These first ones are the nice.

drivers/staging/dgnc/dgnc_tty.c static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, · line 2520

Quoted 7 lines
drivers/staging/dgnc/dgnc_tty.c +2 -1
@@ -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