From 5899f1e020c8d53b2b6fbd6a6cf39c891ccdfade Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Fri, 8 Jan 2010 12:57:02 -0500 Subject: USB: change handling of negative autosuspend delays This patch (as1327) changes the way negative autosuspend delays prevent device from autosuspending. The current code checks for negative values explicitly in the autosuspend_check() routine. The updated code keeps things from getting that far by using usb_autoresume_device() to increment the usage counter when a negative delay is set, and by using usb_autosuspend_device() to decrement the usage counter when a non-negative delay is set. This complicates the set_autosuspend() attribute method code slightly, but it will reduce the overall power management overhead. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/quirks.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/usb/core/quirks.c') diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 4314f25..f073c5c 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -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 */ -- cgit v1.1