linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] rt2x00: use timeout in rt2x00usb_vendor_request
@ 2014-11-26 14:29 Stanislaw Gruszka
  2014-11-26 14:29 ` [PATCH 2/4] rt2x00: change REGISTER_BUSY_COUNT for USB Stanislaw Gruszka
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stanislaw Gruszka @ 2014-11-26 14:29 UTC (permalink / raw)
  To: linux-wireless; +Cc: users, Richard Genoud

Use provided timeout value in rt2x00usb_vendor_request() instead
of iterating REGISTER_BUSY_COUNT times.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/rt2x00/rt2x00usb.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index dc85d3e..258e2a8 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -42,31 +42,27 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
 {
 	struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
 	int status;
-	unsigned int i;
 	unsigned int pipe =
 	    (requesttype == USB_VENDOR_REQUEST_IN) ?
 	    usb_rcvctrlpipe(usb_dev, 0) : usb_sndctrlpipe(usb_dev, 0);
+	unsigned long expire = jiffies + msecs_to_jiffies(timeout);
 
 	if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
 		return -ENODEV;
 
-	for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+	do {
 		status = usb_control_msg(usb_dev, pipe, request, requesttype,
 					 value, offset, buffer, buffer_length,
-					 timeout);
+					 timeout / 2);
 		if (status >= 0)
 			return 0;
 
-		/*
-		 * Check for errors
-		 * -ENODEV: Device has disappeared, no point continuing.
-		 * All other errors: Try again.
-		 */
-		else if (status == -ENODEV) {
+		if (status == -ENODEV) {
+			/* Device has disappeared. */
 			clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
 			break;
 		}
-	}
+	} while (time_before(jiffies, expire));
 
 	/* If the port is powered down, we get a -EPROTO error, and this
 	 * leads to a endless loop. So just say that the device is gone.
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-12-02 16:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 14:29 [PATCH 1/4] rt2x00: use timeout in rt2x00usb_vendor_request Stanislaw Gruszka
2014-11-26 14:29 ` [PATCH 2/4] rt2x00: change REGISTER_BUSY_COUNT for USB Stanislaw Gruszka
2014-11-26 14:29 ` [PATCH 3/4] rt2x00: change REGISTER_TIMEOUT Stanislaw Gruszka
2014-11-26 14:29 ` [PATCH 4/4] Revert "rt2x00: Endless loop on hub port power down" Stanislaw Gruszka
2014-12-02 11:17   ` Richard Genoud
2014-12-02 12:15     ` Stanislaw Gruszka
2014-12-02 16:35       ` Richard Genoud

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).