Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7969
b: refs/heads/master
c: 3ea1596
h: refs/heads/master
i:
  7967: 1251ff3
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Sep 8, 2005
1 parent 8def811 commit 62d0244
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e52b1d3afe698cb77c080ecbe9e745257ff8c81b
refs/heads/master: 3ea15966ed59f2bc20928c7b0496b4585f6de206
10 changes: 9 additions & 1 deletion trunk/drivers/usb/core/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ int usb_trylock_device(struct usb_device *udev)
* is neither BINDING nor BOUND. Rather than sleeping to wait for the
* lock, the routine polls repeatedly. This is to prevent deadlock with
* disconnect; in some drivers (such as usb-storage) the disconnect()
* callback will block waiting for a device reset to complete.
* or suspend() method will block waiting for a device reset to complete.
*
* Returns a negative error code for failure, otherwise 1 or 0 to indicate
* that the device will or will not have to be unlocked. (0 can be
Expand All @@ -922,6 +922,8 @@ int usb_trylock_device(struct usb_device *udev)
int usb_lock_device_for_reset(struct usb_device *udev,
struct usb_interface *iface)
{
unsigned long jiffies_expire = jiffies + HZ;

if (udev->state == USB_STATE_NOTATTACHED)
return -ENODEV;
if (udev->state == USB_STATE_SUSPENDED)
Expand All @@ -938,6 +940,12 @@ int usb_lock_device_for_reset(struct usb_device *udev,
}

while (!usb_trylock_device(udev)) {

/* If we can't acquire the lock after waiting one second,
* we're probably deadlocked */
if (time_after(jiffies, jiffies_expire))
return -EBUSY;

msleep(15);
if (udev->state == USB_STATE_NOTATTACHED)
return -ENODEV;
Expand Down

0 comments on commit 62d0244

Please sign in to comment.