]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
USB: serial: cp210x: return early on unchanged termios
authorJohan Hovold <johan@kernel.org>
Mon, 16 Nov 2020 16:18:21 +0000 (17:18 +0100)
committerJohan Hovold <johan@kernel.org>
Fri, 4 Dec 2020 13:57:20 +0000 (14:57 +0100)
Return early from set_termios() in case no relevant terminal settings
have changed.

This avoids testing each parameter in turn and specifically allows the
line-control handling to be cleaned up further.

Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/cp210x.c

index d0c05aa8a0d6e3f848227da8ca125ab62797f4a3..f1fd109d97d55f8fd9fc32ba7b2552500b46955a 100644 (file)
@@ -1352,6 +1352,15 @@ static void cp210x_disable_event_mode(struct usb_serial_port *port)
        port_priv->event_mode = false;
 }
 
+static bool cp210x_termios_change(const struct ktermios *a, const struct ktermios *b)
+{
+       bool iflag_change;
+
+       iflag_change = ((a->c_iflag ^ b->c_iflag) & INPCK);
+
+       return tty_termios_hw_change(a, b) || iflag_change;
+}
+
 static void cp210x_set_termios(struct tty_struct *tty,
                struct usb_serial_port *port, struct ktermios *old_termios)
 {
@@ -1359,6 +1368,9 @@ static void cp210x_set_termios(struct tty_struct *tty,
        unsigned int cflag, old_cflag;
        u16 bits;
 
+       if (!cp210x_termios_change(&tty->termios, old_termios))
+               return;
+
        cflag = tty->termios.c_cflag;
        old_cflag = old_termios->c_cflag;