Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185321
b: refs/heads/master
c: 5899f1e
h: refs/heads/master
i:
  185319: 86e7b0d
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Mar 2, 2010
1 parent 1bc5ecd commit 902afa1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 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: 088f7fec8a0e683db72fd8826c5d3ab914e197b1
refs/heads/master: 5899f1e020c8d53b2b6fbd6a6cf39c891ccdfade
10 changes: 10 additions & 0 deletions trunk/drivers/usb/core/quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,21 @@ void usb_detect_quirks(struct usb_device *udev)
dev_dbg(&udev->dev, "USB quirks for this device: %x\n",
udev->quirks);

#ifdef CONFIG_USB_SUSPEND

/* By default, disable autosuspend for all devices. The hub driver
* will enable it for hubs.
*/
usb_disable_autosuspend(udev);

/* Autosuspend can also be disabled if the initial autosuspend_delay
* is negative.
*/
if (udev->autosuspend_delay < 0)
usb_autoresume_device(udev);

#endif

/* For the present, all devices default to USB-PERSIST enabled */
#if 0 /* was: #ifdef CONFIG_PM */
/* Hubs are automatically enabled for USB-PERSIST */
Expand Down
22 changes: 17 additions & 5 deletions trunk/drivers/usb/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,21 +346,33 @@ set_autosuspend(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct usb_device *udev = to_usb_device(dev);
int value;
int value, old_delay;
int rc;

if (sscanf(buf, "%d", &value) != 1 || value >= INT_MAX/HZ ||
value <= - INT_MAX/HZ)
return -EINVAL;
value *= HZ;

usb_lock_device(udev);
old_delay = udev->autosuspend_delay;
udev->autosuspend_delay = value;
if (value >= 0)
usb_try_autosuspend_device(udev);
else {
if (usb_autoresume_device(udev) == 0)

if (old_delay < 0) { /* Autosuspend wasn't allowed */
if (value >= 0)
usb_autosuspend_device(udev);
} else { /* Autosuspend was allowed */
if (value < 0) {
rc = usb_autoresume_device(udev);
if (rc < 0) {
count = rc;
udev->autosuspend_delay = old_delay;
}
} else {
usb_try_autosuspend_device(udev);
}
}

usb_unlock_device(udev);
return count;
}
Expand Down

0 comments on commit 902afa1

Please sign in to comment.