Skip to content

Commit 0cbb8c8

Browse files
jhovoldgregkh
authored andcommitted
USB: io_ti: fix chars_in_buffer overhead
commit b16634a upstream. 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 487bc65 commit 0cbb8c8

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
@@ -2033,25 +2033,29 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
20332033
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
20342034
int chars = 0;
20352035
unsigned long flags;
2036-
int ret;
2037-
20382036
if (edge_port == NULL)
20392037
return 0;
20402038

20412039
spin_lock_irqsave(&edge_port->ep_lock, flags);
20422040
chars = kfifo_len(&edge_port->write_fifo);
20432041
spin_unlock_irqrestore(&edge_port->ep_lock, flags);
20442042

2045-
if (!chars) {
2046-
ret = tx_active(edge_port);
2047-
if (ret > 0)
2048-
chars = ret;
2049-
}
2050-
20512043
dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
20522044
return chars;
20532045
}
20542046

2047+
static bool edge_tx_empty(struct usb_serial_port *port)
2048+
{
2049+
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2050+
int ret;
2051+
2052+
ret = tx_active(edge_port);
2053+
if (ret > 0)
2054+
return false;
2055+
2056+
return true;
2057+
}
2058+
20552059
static void edge_throttle(struct tty_struct *tty)
20562060
{
20572061
struct usb_serial_port *port = tty->driver_data;
@@ -2622,6 +2626,7 @@ static struct usb_serial_driver edgeport_1port_device = {
26222626
.write = edge_write,
26232627
.write_room = edge_write_room,
26242628
.chars_in_buffer = edge_chars_in_buffer,
2629+
.tx_empty = edge_tx_empty,
26252630
.break_ctl = edge_break,
26262631
.read_int_callback = edge_interrupt_callback,
26272632
.read_bulk_callback = edge_bulk_in_callback,
@@ -2653,6 +2658,7 @@ static struct usb_serial_driver edgeport_2port_device = {
26532658
.write = edge_write,
26542659
.write_room = edge_write_room,
26552660
.chars_in_buffer = edge_chars_in_buffer,
2661+
.tx_empty = edge_tx_empty,
26562662
.break_ctl = edge_break,
26572663
.read_int_callback = edge_interrupt_callback,
26582664
.read_bulk_callback = edge_bulk_in_callback,

0 commit comments

Comments
 (0)