diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-05-05 14:32:32 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-16 20:32:22 -0400 |
commit | ff93b19eed0d5c124ee7168650a8e2e120ac8ea4 (patch) | |
tree | 57151bdd9f8a28509f2feac7ac3755833395c1e5 | |
parent | b16634adce951a7371be931487034f7365971ed0 (diff) |
USB: ti_usb_3410_5052: 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 2c992cd73 ("USB:
ti_usb_3410_5052: 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>
-rw-r--r-- | drivers/usb/serial/ti_usb_3410_5052.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index cac47aef2918..c92c5ed4e580 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -101,6 +101,7 @@ static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
101 | const unsigned char *data, int count); | 101 | const unsigned char *data, int count); |
102 | static int ti_write_room(struct tty_struct *tty); | 102 | static int ti_write_room(struct tty_struct *tty); |
103 | static int ti_chars_in_buffer(struct tty_struct *tty); | 103 | static int ti_chars_in_buffer(struct tty_struct *tty); |
104 | static bool ti_tx_empty(struct usb_serial_port *port); | ||
104 | static void ti_throttle(struct tty_struct *tty); | 105 | static void ti_throttle(struct tty_struct *tty); |
105 | static void ti_unthrottle(struct tty_struct *tty); | 106 | static void ti_unthrottle(struct tty_struct *tty); |
106 | static int ti_ioctl(struct tty_struct *tty, | 107 | static int ti_ioctl(struct tty_struct *tty, |
@@ -222,6 +223,7 @@ static struct usb_serial_driver ti_1port_device = { | |||
222 | .write = ti_write, | 223 | .write = ti_write, |
223 | .write_room = ti_write_room, | 224 | .write_room = ti_write_room, |
224 | .chars_in_buffer = ti_chars_in_buffer, | 225 | .chars_in_buffer = ti_chars_in_buffer, |
226 | .tx_empty = ti_tx_empty, | ||
225 | .throttle = ti_throttle, | 227 | .throttle = ti_throttle, |
226 | .unthrottle = ti_unthrottle, | 228 | .unthrottle = ti_unthrottle, |
227 | .ioctl = ti_ioctl, | 229 | .ioctl = ti_ioctl, |
@@ -253,6 +255,7 @@ static struct usb_serial_driver ti_2port_device = { | |||
253 | .write = ti_write, | 255 | .write = ti_write, |
254 | .write_room = ti_write_room, | 256 | .write_room = ti_write_room, |
255 | .chars_in_buffer = ti_chars_in_buffer, | 257 | .chars_in_buffer = ti_chars_in_buffer, |
258 | .tx_empty = ti_tx_empty, | ||
256 | .throttle = ti_throttle, | 259 | .throttle = ti_throttle, |
257 | .unthrottle = ti_unthrottle, | 260 | .unthrottle = ti_unthrottle, |
258 | .ioctl = ti_ioctl, | 261 | .ioctl = ti_ioctl, |
@@ -684,8 +687,6 @@ static int ti_chars_in_buffer(struct tty_struct *tty) | |||
684 | struct ti_port *tport = usb_get_serial_port_data(port); | 687 | struct ti_port *tport = usb_get_serial_port_data(port); |
685 | int chars = 0; | 688 | int chars = 0; |
686 | unsigned long flags; | 689 | unsigned long flags; |
687 | int ret; | ||
688 | u8 lsr; | ||
689 | 690 | ||
690 | if (tport == NULL) | 691 | if (tport == NULL) |
691 | return 0; | 692 | return 0; |
@@ -694,16 +695,22 @@ static int ti_chars_in_buffer(struct tty_struct *tty) | |||
694 | chars = kfifo_len(&tport->write_fifo); | 695 | chars = kfifo_len(&tport->write_fifo); |
695 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 696 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
696 | 697 | ||
697 | if (!chars) { | ||
698 | ret = ti_get_lsr(tport, &lsr); | ||
699 | if (!ret && !(lsr & TI_LSR_TX_EMPTY)) | ||
700 | chars = 1; | ||
701 | } | ||
702 | |||
703 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); | 698 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); |
704 | return chars; | 699 | return chars; |
705 | } | 700 | } |
706 | 701 | ||
702 | static bool ti_tx_empty(struct usb_serial_port *port) | ||
703 | { | ||
704 | struct ti_port *tport = usb_get_serial_port_data(port); | ||
705 | int ret; | ||
706 | u8 lsr; | ||
707 | |||
708 | ret = ti_get_lsr(tport, &lsr); | ||
709 | if (!ret && !(lsr & TI_LSR_TX_EMPTY)) | ||
710 | return false; | ||
711 | |||
712 | return true; | ||
713 | } | ||
707 | 714 | ||
708 | static void ti_throttle(struct tty_struct *tty) | 715 | static void ti_throttle(struct tty_struct *tty) |
709 | { | 716 | { |