Patchwork [12/12] usbnet: make device out of suspend before calling usbnet_read/write_cmd

login
register
mail settings
Submitter Ming Lei
Date Oct. 2, 2012, 6:51 a.m.
Message ID <1349160684-6627-13-git-send-email-ming.lei@canonical.com>
Download mbox | patch
Permalink /patch/188406/
State Deferred
Delegated to: David Miller
Headers show

Comments

Ming Lei - Oct. 2, 2012, 6:51 a.m.
This patche gets the runtime PM reference count before calling
usb_control_msg, and puts it after completion of the
usb_control_msg, so that the usb control message can always be
sent to one active device.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/net/usb/usbnet.c |    4 ++++
 1 file changed, 4 insertions(+)
Oliver Neukum - Oct. 9, 2012, 8:50 a.m.
On Tuesday 02 October 2012 14:51:23 Ming Lei wrote:
> This patche gets the runtime PM reference count before calling
> usb_control_msg, and puts it after completion of the
> usb_control_msg, so that the usb control message can always be
> sent to one active device.

This is awkward to use in suspend()/resume()
Could you make both versions available?

	Regards
		Oliver

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 3b51554..3f4bc69 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1609,9 +1609,11 @@  int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
 			goto out;
 	}
 
+	usb_autopm_get_interface(dev->intf);
 	err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
 			      cmd, reqtype, value, index, buf, size,
 			      USB_CTRL_GET_TIMEOUT);
+	usb_autopm_put_interface(dev->intf);
 	if (err > 0 && err <= size)
 		memcpy(data, buf, err);
 	kfree(buf);
@@ -1636,9 +1638,11 @@  int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
 			goto out;
 	}
 
+	usb_autopm_get_interface(dev->intf);
 	err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
 			      cmd, reqtype, value, index, buf, size,
 			      USB_CTRL_SET_TIMEOUT);
+	usb_autopm_put_interface(dev->intf);
 	kfree(buf);
 
 out: