serial: Use B0 instead of implicit zero assumption
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 9 Mar 2023 08:09:17 +0000 (10:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 14:00:40 +0000 (15:00 +0100)
Compare against B0 rather than assume B0 equals zero, which is true for
all archs but explicit B0 makes the code more obvious.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230309080923.11778-3-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c

index ee2aabc..296d2c3 100644 (file)
@@ -1662,10 +1662,10 @@ static void uart_set_termios(struct tty_struct *tty,
        cflag = tty->termios.c_cflag;
 
        /* Handle transition to B0 status */
-       if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD))
+       if (((old_termios->c_cflag & CBAUD) != B0) && ((cflag & CBAUD) == B0))
                uart_clear_mctrl(uport, TIOCM_RTS | TIOCM_DTR);
        /* Handle transition away from B0 status */
-       else if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
+       else if (((old_termios->c_cflag & CBAUD) == B0) && ((cflag & CBAUD) != B0)) {
                unsigned int mask = TIOCM_DTR;
 
                if (!(cflag & CRTSCTS) || !tty_throttled(tty))