Skip to content

Commit

Permalink
usbnet: runtime wake up device before calling usbnet_{read|write}_cmd
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ming Lei authored and David S. Miller committed Nov 7, 2012
1 parent ec32115 commit 6f0a098
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions drivers/net/usb/usbnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,8 +1670,14 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
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);

Expand All @@ -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);

Expand Down

0 comments on commit 6f0a098

Please sign in to comment.