PM: Allow USB devices to suspend/resume asynchronously
authorRafael J. Wysocki <rjw@sisk.pl>
Mon, 8 Feb 2010 18:18:16 +0000 (19:18 +0100)
committerRafael J. Wysocki <rjw@sisk.pl>
Fri, 26 Feb 2010 19:39:12 +0000 (20:39 +0100)
Set power.async_suspend for USB devices, endpoints and interfaces,
allowing them to be suspended and resumed asynchronously during
system sleep transitions.

The power.async_suspend flag is also set for devices that don't have
suspend or resume callbacks, because otherwise they would make the
main suspend/resume thread wait for their "asynchronous" children
(during suspend) or parents (during resume), effectively negating the
possible gains from executing these devices' suspend and resume
callbacks asynchronously.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
drivers/usb/core/endpoint.c
drivers/usb/core/hub.c
drivers/usb/core/message.c

index fdfaa7885515d075330921d17442bbc80f1dcf06..d26b9ea981f92f322c5c402f38e53d7c075e7e52 100644 (file)
@@ -186,6 +186,7 @@ int usb_create_ep_devs(struct device *parent,
        ep_dev->dev.parent = parent;
        ep_dev->dev.release = ep_device_release;
        dev_set_name(&ep_dev->dev, "ep_%02x", endpoint->desc.bEndpointAddress);
+       device_enable_async_suspend(&ep_dev->dev);
 
        retval = device_register(&ep_dev->dev);
        if (retval)
index 35cc8b9ba1f5bfab21331d6241a529ca2b3de304..20ecb4cec8de56540f507d459c205b51151da148 100644 (file)
@@ -1817,6 +1817,7 @@ int usb_new_device(struct usb_device *udev)
        /* Tell the world! */
        announce_device(udev);
 
+       device_enable_async_suspend(&udev->dev);
        /* Register the device.  The device driver is responsible
         * for configuring the device and invoking the add-device
         * notifier chain (used by usbfs and possibly others).
index 9bc95fec793fa674727d19c53820853c128afabb..df73574a9cc9e567fc621a00d935f423923ac762 100644 (file)
@@ -1867,6 +1867,7 @@ free_interfaces:
                        "adding %s (config #%d, interface %d)\n",
                        dev_name(&intf->dev), configuration,
                        intf->cur_altsetting->desc.bInterfaceNumber);
+               device_enable_async_suspend(&intf->dev);
                ret = device_add(&intf->dev);
                if (ret != 0) {
                        dev_err(&dev->dev, "device_add(%s) --> %d\n",