Commit ad92bc9e authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by John W. Linville

rt2x00: use timeout in rt2x00usb_vendor_request

Use provided timeout value in rt2x00usb_vendor_request() instead
of iterating REGISTER_BUSY_COUNT times.
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 4cc2fa00
...@@ -42,31 +42,27 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev, ...@@ -42,31 +42,27 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
{ {
struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev); struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
int status; int status;
unsigned int i;
unsigned int pipe = unsigned int pipe =
(requesttype == USB_VENDOR_REQUEST_IN) ? (requesttype == USB_VENDOR_REQUEST_IN) ?
usb_rcvctrlpipe(usb_dev, 0) : usb_sndctrlpipe(usb_dev, 0); 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)) if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
return -ENODEV; return -ENODEV;
for (i = 0; i < REGISTER_BUSY_COUNT; i++) { do {
status = usb_control_msg(usb_dev, pipe, request, requesttype, status = usb_control_msg(usb_dev, pipe, request, requesttype,
value, offset, buffer, buffer_length, value, offset, buffer, buffer_length,
timeout); timeout / 2);
if (status >= 0) if (status >= 0)
return 0; return 0;
/* if (status == -ENODEV) {
* Check for errors /* Device has disappeared. */
* -ENODEV: Device has disappeared, no point continuing.
* All other errors: Try again.
*/
else if (status == -ENODEV) {
clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
break; break;
} }
} } while (time_before(jiffies, expire));
/* If the port is powered down, we get a -EPROTO error, and this /* 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. * leads to a endless loop. So just say that the device is gone.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment