On Tuesday 02 October 2012 14:51:12 Ming Lei wrote:
quoted hunk ↗ jump to hunk
This patch introduces the below 3 usb command helpers:
usbnet_read_cmd / usbnet_write_cmd / usbnet_write_cmd_async
so that each low level driver doesn't need to implement them
by itself, and the dma buffer allocation for usb transfer and
runtime PM things can be handled just in one place.
Signed-off-by: Ming Lei <redacted>
---
drivers/net/usb/usbnet.c | 133 ++++++++++++++++++++++++++++++++++++++++++++
include/linux/usb/usbnet.h | 6 ++
2 files changed, 139 insertions(+)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index fc9f578..3b51554 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1592,6 +1592,139 @@ int usbnet_resume (struct usb_interface *intf)
}
EXPORT_SYMBOL_GPL(usbnet_resume);
+/*-------------------------------------------------------------------------*/
+int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
+ u16 value, u16 index, void *data, u16 size)
+{
+ void *buf = NULL;
+ int err = -ENOMEM;
+
+ netdev_dbg(dev->net, "usbnet_read_cmd cmd=0x%02x reqtype=%02x"
+ " value=0x%04x index=0x%04x size=%d\n",
+ cmd, reqtype, value, index, size);
+
+ if (data) {
+ buf = kmalloc(size, GFP_KERNEL);
Using GFP_KERNEL you preclude using those in resume() and error handling.
Please pass a gfp_t parameter.
Regards
Oliver