Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+16 -10
+16 -10
drivers/usb/serial/kobil_sct.c
··· 435 435 { 436 436 struct kobil_private *priv; 437 437 int result; 438 - unsigned short urb_val = 0; 439 438 int c_cflag = tty->termios.c_cflag; 440 439 speed_t speed; 440 + u16 val; 441 441 442 442 priv = usb_get_serial_port_data(port); 443 443 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || ··· 450 450 speed = tty_get_baud_rate(tty); 451 451 switch (speed) { 452 452 case 1200: 453 - urb_val = SUSBCR_SBR_1200; 453 + val = SUSBCR_SBR_1200; 454 454 break; 455 455 default: 456 456 speed = 9600; 457 457 fallthrough; 458 458 case 9600: 459 - urb_val = SUSBCR_SBR_9600; 459 + val = SUSBCR_SBR_9600; 460 460 break; 461 461 } 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 + 464 468 if (c_cflag & PARENB) { 465 469 if (c_cflag & PARODD) 466 - urb_val |= SUSBCR_SPASB_OddParity; 470 + val |= SUSBCR_SPASB_OddParity; 467 471 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 + 471 477 tty->termios.c_cflag &= ~CMSPAR; 472 478 tty_encode_baud_rate(tty, speed, speed); 473 479 474 - result = kobil_ctrl_send(port, SUSBCRequest_SetBaudRateParityAndStopBits, urb_val); 480 + result = kobil_ctrl_send(port, SUSBCRequest_SetBaudRateParityAndStopBits, val); 475 481 if (result) { 476 482 dev_err(&port->dev, "failed to update line settings: %d\n", 477 483 result);