]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
USB: serial: kobil_sct: clean up set_termios()
authorJohan Hovold <johan@kernel.org>
Wed, 22 Oct 2025 15:26:39 +0000 (17:26 +0200)
committerJohan Hovold <johan@kernel.org>
Mon, 27 Oct 2025 08:22:21 +0000 (09:22 +0100)
Clean up set_termios() by using a shorter identifier for the control
request value, replacing a ternary operator and adding some missing
braces to make it more readable.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/kobil_sct.c

index 3c13410520ecf442160c07a232006b3a8cb32897..cad3cfc63ce7b14e7e4df5835ecfe3d28945307e 100644 (file)
@@ -435,9 +435,9 @@ static void kobil_set_termios(struct tty_struct *tty,
 {
        struct kobil_private *priv;
        int result;
-       unsigned short urb_val = 0;
        int c_cflag = tty->termios.c_cflag;
        speed_t speed;
+       u16 val;
 
        priv = usb_get_serial_port_data(port);
        if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
@@ -450,28 +450,34 @@ static void kobil_set_termios(struct tty_struct *tty,
        speed = tty_get_baud_rate(tty);
        switch (speed) {
        case 1200:
-               urb_val = SUSBCR_SBR_1200;
+               val = SUSBCR_SBR_1200;
                break;
        default:
                speed = 9600;
                fallthrough;
        case 9600:
-               urb_val = SUSBCR_SBR_9600;
+               val = SUSBCR_SBR_9600;
                break;
        }
-       urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits :
-                                                       SUSBCR_SPASB_1StopBit;
+
+       if (c_cflag & CSTOPB)
+               val |= SUSBCR_SPASB_2StopBits;
+       else
+               val |= SUSBCR_SPASB_1StopBit;
+
        if (c_cflag & PARENB) {
                if  (c_cflag & PARODD)
-                       urb_val |= SUSBCR_SPASB_OddParity;
+                       val |= SUSBCR_SPASB_OddParity;
                else
-                       urb_val |= SUSBCR_SPASB_EvenParity;
-       } else
-               urb_val |= SUSBCR_SPASB_NoParity;
+                       val |= SUSBCR_SPASB_EvenParity;
+       } else {
+               val |= SUSBCR_SPASB_NoParity;
+       }
+
        tty->termios.c_cflag &= ~CMSPAR;
        tty_encode_baud_rate(tty, speed, speed);
 
-       result = kobil_ctrl_send(port, SUSBCRequest_SetBaudRateParityAndStopBits, urb_val);
+       result = kobil_ctrl_send(port, SUSBCRequest_SetBaudRateParityAndStopBits, val);
        if (result) {
                dev_err(&port->dev, "failed to update line settings: %d\n",
                                result);