tty: jsm_tty, make char+error handling readable
authorJiri Slaby <jslaby@suse.cz>
Tue, 2 Mar 2021 06:21:51 +0000 (07:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Mar 2021 08:34:07 +0000 (09:34 +0100)
The code for char+error handling in jsm_input was complete mess of
letters. Introduce 3 new local variables and use them with care.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210302062214.29627-21-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/jsm/jsm_tty.c

index 512b771..8e42a76 100644 (file)
@@ -603,18 +603,22 @@ void jsm_input(struct jsm_channel *ch)
 
                if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) {
                        for (i = 0; i < s; i++) {
+                               u8 chr   = ch->ch_rqueue[tail + i];
+                               u8 error = ch->ch_equeue[tail + i];
+                               char flag = TTY_NORMAL;
+
                                /*
-                                * Give the Linux ld the flags in the
-                                * format it likes.
+                                * Give the Linux ld the flags in the format it
+                                * likes.
                                 */
-                               if (*(ch->ch_equeue + tail + i) & UART_LSR_BI)
-                                       tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i),  TTY_BREAK);
-                               else if (*(ch->ch_equeue +tail +i) & UART_LSR_PE)
-                                       tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_PARITY);
-                               else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE)
-                                       tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_FRAME);
-                               else
-                                       tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_NORMAL);
+                               if (error & UART_LSR_BI)
+                                       flag = TTY_BREAK;
+                               else if (error & UART_LSR_PE)
+                                       flag = TTY_PARITY;
+                               else if (error & UART_LSR_FE)
+                                       flag = TTY_FRAME;
+
+                               tty_insert_flip_char(port, chr, flag);
                        }
                } else {
                        tty_insert_flip_string(port, ch->ch_rqueue + tail, s);