lkml.org 
[lkml]   [2009]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] USB: ftdi_sio: Fix read regression in 2.6.31.
Use ASYNCB_INITIALIZED to determine when to stop reading.

Since 335f8514f200e63d689113d29cb7253a5c282967 port count can no longer
be used to determine when to stop reading from the device as it can be
zero when the first read callbacks are made (see tty_port_block_til_read
where port count is temporarily decremented during serial_open).

This fixes the regression where reads fail after connecting the device
and opening the port more than once (reads usually succeed after the
first open due to the device latency timer then being set to the default
16ms rather than 1ms).

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---

Tested against 2.6.31 as well as Greg's patch set
(f9752c181c0f7d8bc9c16df0124bf06c5a4d4d88).

Note that ASYNCB_INITIALIZED does not yet get cleared on close in
2.6.31 (as it does in Greg's patches), but ftdi_close kills the urb so
the driver stops reading at the next callback as the urb status then is
non-zero.

Regards,
Johan


drivers/usb/serial/ftdi_sio.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 4f883b1..7eaea14 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2033,7 +2033,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)

dbg("%s - port %d", __func__, port->number);

- if (port->port.count <= 0)
+ if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
return;

tty = tty_port_tty_get(&port->port);
@@ -2089,7 +2089,7 @@ static void ftdi_process_read(struct work_struct *work)

dbg("%s - port %d", __func__, port->number);

- if (port->port.count <= 0)
+ if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
return;

tty = tty_port_tty_get(&port->port);
@@ -2247,7 +2247,7 @@ static void ftdi_process_read(struct work_struct *work)
}
spin_unlock_irqrestore(&priv->rx_lock, flags);
/* if the port is closed stop trying to read */
- if (port->port.count > 0)
+ if (test_bit(ASYNCB_INITIALIZED, &port->port.flags))
/* delay processing of remainder */
schedule_delayed_work(&priv->rx_work, 1);
else
@@ -2259,7 +2259,7 @@ static void ftdi_process_read(struct work_struct *work)
priv->rx_processed = 0;

/* if the port is closed stop trying to read */
- if (port->port.count > 0) {
+ if (test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
/* Continue trying to always read */
usb_fill_bulk_urb(port->read_urb, port->serial->dev,
usb_rcvbulkpipe(port->serial->dev,
--
1.6.4.2


\
 
 \ /
  Last update: 2009-09-19 18:07    [W:1.356 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site