public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <jhovold@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Alan Stern <stern@rowland.harvard.edu>,
	linux-usb@vger.kernel.org, e9hack <e9hack@googlemail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] USB: ftdi_sio: Fix read regression in 2.6.31.
Date: Sat, 19 Sep 2009 18:03:47 +0200	[thread overview]
Message-ID: <20090919160347.GA14156@localhost> (raw)
In-Reply-To: <20090916162640.2840db66@lxorguk.ukuu.org.uk>

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


       reply	other threads:[~2009-09-19 16:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090916162640.2840db66@lxorguk.ukuu.org.uk>
2009-09-19 16:03 ` Johan Hovold [this message]
2009-09-19 16:20   ` [PATCH] USB: ftdi_sio: Fix read regression in 2.6.31 Alan Stern
2009-09-19 16:36     ` Johan Hovold
2009-09-20 20:18     ` [PATCH] USB: serial: " Johan Hovold
2009-10-09 17:56       ` Greg KH
2009-10-09 18:41         ` Johan Hovold
2009-10-09 19:09           ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090919160347.GA14156@localhost \
    --to=jhovold@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=e9hack@googlemail.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox