Skip to content

Commit

Permalink
USB: io_ti: fix chars_in_buffer overhead
Browse files Browse the repository at this point in the history
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 <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed May 17, 2013
1 parent a37025b commit b16634a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions drivers/usb/serial/io_ti.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,25 +2019,29 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int chars = 0;
unsigned long flags;
int ret;

if (edge_port == NULL)
return 0;

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

if (!chars) {
ret = tx_active(edge_port);
if (ret > 0)
chars = ret;
}

dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
return chars;
}

static bool edge_tx_empty(struct usb_serial_port *port)
{
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int ret;

ret = tx_active(edge_port);
if (ret > 0)
return false;

return true;
}

static void edge_throttle(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
Expand Down Expand Up @@ -2557,6 +2561,7 @@ static struct usb_serial_driver edgeport_1port_device = {
.write = edge_write,
.write_room = edge_write_room,
.chars_in_buffer = edge_chars_in_buffer,
.tx_empty = edge_tx_empty,
.break_ctl = edge_break,
.read_int_callback = edge_interrupt_callback,
.read_bulk_callback = edge_bulk_in_callback,
Expand Down Expand Up @@ -2589,6 +2594,7 @@ static struct usb_serial_driver edgeport_2port_device = {
.write = edge_write,
.write_room = edge_write_room,
.chars_in_buffer = edge_chars_in_buffer,
.tx_empty = edge_tx_empty,
.break_ctl = edge_break,
.read_int_callback = edge_interrupt_callback,
.read_bulk_callback = edge_bulk_in_callback,
Expand Down

0 comments on commit b16634a

Please sign in to comment.