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

USB: serial: f81232: implement break control

Implement Fintek F81232 break on/off with LCR register.
It's the same with 16550A LCR register layout.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
[ johan: fix corrupt line settings on break due to missing shadow_lcr
update in set_termios() ]
Signed-off-by: Johan Hovold <johan@kernel.org>

authored by

Ji-Ze Hong (Peter Hong) and committed by
Johan Hovold
7f6fc502 268ddb5e

+25 -6
+25 -6
drivers/usb/serial/f81232.c
··· 65 65 struct mutex lock; 66 66 u8 modem_control; 67 67 u8 modem_status; 68 + u8 shadow_lcr; 68 69 speed_t baud_base; 69 70 struct work_struct lsr_work; 70 71 struct work_struct interrupt_work; ··· 378 377 379 378 static void f81232_break_ctl(struct tty_struct *tty, int break_state) 380 379 { 381 - /* FIXME - Stubbed out for now */ 380 + struct usb_serial_port *port = tty->driver_data; 381 + struct f81232_private *priv = usb_get_serial_port_data(port); 382 + int status; 382 383 383 - /* 384 - * break_state = -1 to turn on break, and 0 to turn off break 385 - * see drivers/char/tty_io.c to see it used. 386 - * last_set_data_urb_value NEVER has the break bit set in it. 387 - */ 384 + mutex_lock(&priv->lock); 385 + 386 + if (break_state) 387 + priv->shadow_lcr |= UART_LCR_SBC; 388 + else 389 + priv->shadow_lcr &= ~UART_LCR_SBC; 390 + 391 + status = f81232_set_register(port, LINE_CONTROL_REGISTER, 392 + priv->shadow_lcr); 393 + if (status) 394 + dev_err(&port->dev, "set break failed: %d\n", status); 395 + 396 + mutex_unlock(&priv->lock); 388 397 } 389 398 390 399 static int f81232_find_clk(speed_t baudrate) ··· 530 519 static void f81232_set_termios(struct tty_struct *tty, 531 520 struct usb_serial_port *port, struct ktermios *old_termios) 532 521 { 522 + struct f81232_private *priv = usb_get_serial_port_data(port); 533 523 u8 new_lcr = 0; 534 524 int status = 0; 535 525 speed_t baudrate; ··· 584 572 break; 585 573 } 586 574 575 + mutex_lock(&priv->lock); 576 + 577 + new_lcr |= (priv->shadow_lcr & UART_LCR_SBC); 587 578 status = f81232_set_register(port, LINE_CONTROL_REGISTER, new_lcr); 588 579 if (status) { 589 580 dev_err(&port->dev, "%s failed to set LCR: %d\n", 590 581 __func__, status); 591 582 } 583 + 584 + priv->shadow_lcr = new_lcr; 585 + 586 + mutex_unlock(&priv->lock); 592 587 } 593 588 594 589 static int f81232_tiocmget(struct tty_struct *tty)