]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usbnet: runtime wake up device before calling usbnet_{read|write}_cmd
authorMing Lei <ming.lei@canonical.com>
Tue, 6 Nov 2012 04:53:08 +0000 (04:53 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 7 Nov 2012 08:53:38 +0000 (03:53 -0500)
This patch gets the runtime PM reference count before calling
usbnet_{read|write}_cmd, and puts it after completion of the
usbnet_{read|write}_cmd, so that the usb control message can always
be sent to one active device in the non-PM context.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/usbnet.c

index 0ac1ff3571cb92e671ddbdbf5c9fee038f875cd6..5bf77171f4520ec80f01510294f3dec37342beb0 100644 (file)
@@ -1670,8 +1670,14 @@ out:
 int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
                    u16 value, u16 index, void *data, u16 size)
 {
-       return __usbnet_read_cmd(dev, cmd, reqtype, value, index,
-                                data, size);
+       int ret;
+
+       if (usb_autopm_get_interface(dev->intf) < 0)
+               return -ENODEV;
+       ret = __usbnet_read_cmd(dev, cmd, reqtype, value, index,
+                               data, size);
+       usb_autopm_put_interface(dev->intf);
+       return ret;
 }
 EXPORT_SYMBOL_GPL(usbnet_read_cmd);
 
@@ -1682,8 +1688,14 @@ EXPORT_SYMBOL_GPL(usbnet_read_cmd);
 int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
                     u16 value, u16 index, const void *data, u16 size)
 {
-       return __usbnet_write_cmd(dev, cmd, reqtype, value, index,
-                                 data, size);
+       int ret;
+
+       if (usb_autopm_get_interface(dev->intf) < 0)
+               return -ENODEV;
+       ret = __usbnet_write_cmd(dev, cmd, reqtype, value, index,
+                                data, size);
+       usb_autopm_put_interface(dev->intf);
+       return ret;
 }
 EXPORT_SYMBOL_GPL(usbnet_write_cmd);