Skip to content

Commit b16634a

Browse files
jhovoldgregkh
authored andcommitted
USB: io_ti: 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 263e1f9 ("USB: io_ti: query hardware-buffer status in chars_in_buffer") without breaking tty_wait_until_sent (used by, for example, tcdrain, tcsendbreak and close). Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a37025b commit b16634a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

drivers/usb/serial/io_ti.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,25 +2019,29 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
20192019
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
20202020
int chars = 0;
20212021
unsigned long flags;
2022-
int ret;
2023-
20242022
if (edge_port == NULL)
20252023
return 0;
20262024

20272025
spin_lock_irqsave(&edge_port->ep_lock, flags);
20282026
chars = kfifo_len(&edge_port->write_fifo);
20292027
spin_unlock_irqrestore(&edge_port->ep_lock, flags);
20302028

2031-
if (!chars) {
2032-
ret = tx_active(edge_port);
2033-
if (ret > 0)
2034-
chars = ret;
2035-
}
2036-
20372029
dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
20382030
return chars;
20392031
}
20402032

2033+
static bool edge_tx_empty(struct usb_serial_port *port)
2034+
{
2035+
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2036+
int ret;
2037+
2038+
ret = tx_active(edge_port);
2039+
if (ret > 0)
2040+
return false;
2041+
2042+
return true;
2043+
}
2044+
20412045
static void edge_throttle(struct tty_struct *tty)
20422046
{
20432047
struct usb_serial_port *port = tty->driver_data;
@@ -2557,6 +2561,7 @@ static struct usb_serial_driver edgeport_1port_device = {
25572561
.write = edge_write,
25582562
.write_room = edge_write_room,
25592563
.chars_in_buffer = edge_chars_in_buffer,
2564+
.tx_empty = edge_tx_empty,
25602565
.break_ctl = edge_break,
25612566
.read_int_callback = edge_interrupt_callback,
25622567
.read_bulk_callback = edge_bulk_in_callback,
@@ -2589,6 +2594,7 @@ static struct usb_serial_driver edgeport_2port_device = {
25892594
.write = edge_write,
25902595
.write_room = edge_write_room,
25912596
.chars_in_buffer = edge_chars_in_buffer,
2597+
.tx_empty = edge_tx_empty,
25922598
.break_ctl = edge_break,
25932599
.read_int_callback = edge_interrupt_callback,
25942600
.read_bulk_callback = edge_bulk_in_callback,

0 commit comments

Comments
 (0)