diff options
author | Ming Lei <ming.lei@canonical.com> | 2012-11-06 04:53:08 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-07 03:53:38 -0500 |
commit | 6f0a0986e328dd61610d898a09c9f4aa960ae64a (patch) | |
tree | 8f977eceb56500f10eb5c9e2480622649d78af14 /drivers/net/usb/usbnet.c | |
parent | ec32115db2bcb7133171c6a036107ca7eb62267f (diff) | |
download | blackbird-obmc-linux-6f0a0986e328dd61610d898a09c9f4aa960ae64a.tar.gz blackbird-obmc-linux-6f0a0986e328dd61610d898a09c9f4aa960ae64a.zip |
usbnet: runtime wake up device before calling usbnet_{read|write}_cmd
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>
Diffstat (limited to 'drivers/net/usb/usbnet.c')
-rw-r--r-- | drivers/net/usb/usbnet.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 0ac1ff3571cb..5bf77171f452 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -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); |