]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
USB: don't let errors prevent system sleep
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 15 Jun 2011 20:27:43 +0000 (16:27 -0400)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Thu, 17 May 2012 15:21:03 +0000 (11:21 -0400)
commit 0af212ba8f123c2eba151af7726c34a50b127962 upstream.

This patch (as1464) implements the recommended policy that most errors
during suspend or hibernation should not prevent the system from going
to sleep.  In particular, failure to suspend a USB driver or a USB
device should not prevent the sleep from succeeding:

Failure to suspend a device won't matter, because the device will
automatically go into suspend mode when the USB bus stops carrying
packets.  (This might be less true for USB-3.0 devices, but let's not
worry about them now.)

Failure of a driver to suspend might lead to trouble later on when the
system wakes up, but it isn't sufficient reason to prevent the system
from going to sleep.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
drivers/usb/core/driver.c

index 212b5e8231d4d898c12b3b8c74ed9ed3d26c6a26..f045f19b7ec69bbe0c7bdbcf27c89b8bf61a8ba4 100644 (file)
@@ -1183,13 +1183,22 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
                for (i = n - 1; i >= 0; --i) {
                        intf = udev->actconfig->interface[i];
                        status = usb_suspend_interface(udev, intf, msg);
+
+                       /* Ignore errors during system sleep transitions */
+                       if (!(msg.event & PM_EVENT_AUTO))
+                               status = 0;
                        if (status != 0)
                                break;
                }
        }
-       if (status == 0)
+       if (status == 0) {
                status = usb_suspend_device(udev, msg);
 
+               /* Again, ignore errors during system sleep transitions */
+               if (!(msg.event & PM_EVENT_AUTO))
+                       status = 0;
+       }
+
        /* If the suspend failed, resume interfaces that did get suspended */
        if (status != 0) {
                msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME);