usbnet: handle PM failure gracefully
authorOliver Neukum <oliver@neukum.org>
Tue, 18 Dec 2012 04:45:29 +0000 (04:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Dec 2012 20:46:40 +0000 (12:46 -0800)
If a device fails to do remote wakeup, this is no reason
to abort an open totally. This patch just continues without
runtime PM.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/usbnet.c
include/linux/usb/usbnet.h

index c04110ba677f5febcac3876a411646845b3a9ab3..50ed7ab09c9f2628984727784a66d534db7ab153 100644 (file)
@@ -719,7 +719,8 @@ int usbnet_stop (struct net_device *net)
        dev->flags = 0;
        del_timer_sync (&dev->delay);
        tasklet_kill (&dev->bh);
-       if (info->manage_power)
+       if (info->manage_power &&
+           !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags))
                info->manage_power(dev, 0);
        else
                usb_autopm_put_interface(dev->intf);
@@ -794,14 +795,14 @@ int usbnet_open (struct net_device *net)
        tasklet_schedule (&dev->bh);
        if (info->manage_power) {
                retval = info->manage_power(dev, 1);
-               if (retval < 0)
-                       goto done_manage_power_error;
-               usb_autopm_put_interface(dev->intf);
+               if (retval < 0) {
+                       retval = 0;
+                       set_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
+               } else {
+                       usb_autopm_put_interface(dev->intf);
+               }
        }
        return retval;
-
-done_manage_power_error:
-       clear_bit(EVENT_DEV_OPEN, &dev->flags);
 done:
        usb_autopm_put_interface(dev->intf);
 done_nopm:
index 9bbeabf66c54d59cede412db6084c1e4315f2d48..288b32aadab29df211c53410af2e788a0f15d220 100644 (file)
@@ -69,6 +69,7 @@ struct usbnet {
 #              define EVENT_DEV_ASLEEP 6
 #              define EVENT_DEV_OPEN   7
 #              define EVENT_DEVICE_REPORT_IDLE 8
+#              define EVENT_NO_RUNTIME_PM      9
 };
 
 static inline struct usb_driver *driver_of(struct usb_interface *intf)