Skip to content

Commit d99bdbb

Browse files
committed
USB: serial: kobil_sct: clean up set_termios()
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>
1 parent 754640d commit d99bdbb

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

drivers/usb/serial/kobil_sct.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ static void kobil_set_termios(struct tty_struct *tty,
435435
{
436436
struct kobil_private *priv;
437437
int result;
438-
unsigned short urb_val = 0;
439438
int c_cflag = tty->termios.c_cflag;
440439
speed_t speed;
440+
u16 val;
441441

442442
priv = usb_get_serial_port_data(port);
443443
if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
@@ -450,28 +450,34 @@ static void kobil_set_termios(struct tty_struct *tty,
450450
speed = tty_get_baud_rate(tty);
451451
switch (speed) {
452452
case 1200:
453-
urb_val = SUSBCR_SBR_1200;
453+
val = SUSBCR_SBR_1200;
454454
break;
455455
default:
456456
speed = 9600;
457457
fallthrough;
458458
case 9600:
459-
urb_val = SUSBCR_SBR_9600;
459+
val = SUSBCR_SBR_9600;
460460
break;
461461
}
462-
urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits :
463-
SUSBCR_SPASB_1StopBit;
462+
463+
if (c_cflag & CSTOPB)
464+
val |= SUSBCR_SPASB_2StopBits;
465+
else
466+
val |= SUSBCR_SPASB_1StopBit;
467+
464468
if (c_cflag & PARENB) {
465469
if (c_cflag & PARODD)
466-
urb_val |= SUSBCR_SPASB_OddParity;
470+
val |= SUSBCR_SPASB_OddParity;
467471
else
468-
urb_val |= SUSBCR_SPASB_EvenParity;
469-
} else
470-
urb_val |= SUSBCR_SPASB_NoParity;
472+
val |= SUSBCR_SPASB_EvenParity;
473+
} else {
474+
val |= SUSBCR_SPASB_NoParity;
475+
}
476+
471477
tty->termios.c_cflag &= ~CMSPAR;
472478
tty_encode_baud_rate(tty, speed, speed);
473479

474-
result = kobil_ctrl_send(port, SUSBCRequest_SetBaudRateParityAndStopBits, urb_val);
480+
result = kobil_ctrl_send(port, SUSBCRequest_SetBaudRateParityAndStopBits, val);
475481
if (result) {
476482
dev_err(&port->dev, "failed to update line settings: %d\n",
477483
result);

0 commit comments

Comments
 (0)