Skip to content

Commit a37025b

Browse files
jhovoldgregkh
authored andcommitted
USB: ftdi_sio: fix chars_in_buffer overhead
Use the new generic usb-serial wait_until_sent implementation to wait for hardware buffers to drain. This removes the need to check the hardware buffers in chars_in_buffer and thus removes the overhead introduced by commit 6f60291 ("usb: serial: ftdi_sio: Add missing chars_in_buffer function") without breaking tty_wait_until_sent (used by, for example, tcdrain, tcsendbreak and close). Reported-by: Stas Sergeev <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c413364 commit a37025b

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

drivers/usb/serial/ftdi_sio.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ static int ftdi_tiocmset(struct tty_struct *tty,
924924
static int ftdi_ioctl(struct tty_struct *tty,
925925
unsigned int cmd, unsigned long arg);
926926
static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
927-
static int ftdi_chars_in_buffer(struct tty_struct *tty);
927+
static bool ftdi_tx_empty(struct usb_serial_port *port);
928928
static int ftdi_get_modem_status(struct usb_serial_port *port,
929929
unsigned char status[2]);
930930

@@ -961,7 +961,7 @@ static struct usb_serial_driver ftdi_sio_device = {
961961
.ioctl = ftdi_ioctl,
962962
.set_termios = ftdi_set_termios,
963963
.break_ctl = ftdi_break_ctl,
964-
.chars_in_buffer = ftdi_chars_in_buffer,
964+
.tx_empty = ftdi_tx_empty,
965965
};
966966

967967
static struct usb_serial_driver * const serial_drivers[] = {
@@ -2056,27 +2056,18 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
20562056

20572057
}
20582058

2059-
static int ftdi_chars_in_buffer(struct tty_struct *tty)
2059+
static bool ftdi_tx_empty(struct usb_serial_port *port)
20602060
{
2061-
struct usb_serial_port *port = tty->driver_data;
2062-
int chars;
20632061
unsigned char buf[2];
20642062
int ret;
20652063

2066-
chars = usb_serial_generic_chars_in_buffer(tty);
2067-
if (chars)
2068-
goto out;
2069-
2070-
/* Check if hardware buffer is empty. */
20712064
ret = ftdi_get_modem_status(port, buf);
20722065
if (ret == 2) {
20732066
if (!(buf[1] & FTDI_RS_TEMT))
2074-
chars = 1;
2067+
return false;
20752068
}
2076-
out:
2077-
dev_dbg(&port->dev, "%s - %d\n", __func__, chars);
20782069

2079-
return chars;
2070+
return true;
20802071
}
20812072

20822073
/* old_termios contains the original termios settings and tty->termios contains

0 commit comments

Comments
 (0)