HID: roccat: Use kmemdup rather than duplicating its implementation
authorThomas Meyer <thomas@m3y3r.de>
Thu, 17 Nov 2011 22:43:40 +0000 (23:43 +0100)
committerJiri Kosina <jkosina@suse.cz>
Sat, 19 Nov 2011 23:42:42 +0000 (00:42 +0100)
Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-roccat-common.c
drivers/hid/hid-roccat-kone.c

index edf898dee28bd177a0e7c4fc7a40971aee72e457..f933221ba525bd3c918c2c1ac0b1c4a6e8e58a87 100644 (file)
@@ -48,12 +48,10 @@ int roccat_common_send(struct usb_device *usb_dev, uint report_id,
        char *buf;
        int len;
 
-       buf = kmalloc(size, GFP_KERNEL);
+       buf = kmemdup(data, size, GFP_KERNEL);
        if (buf == NULL)
                return -ENOMEM;
 
-       memcpy(buf, data, size);
-
        len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
                        HID_REQ_SET_REPORT,
                        USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
index e2072afb34bbb7dce51c9bdb3b44f5b2867e9bd3..40090d602158bf06e03297edb40aa0c00edcd7f6 100644 (file)
@@ -78,12 +78,10 @@ static int kone_send(struct usb_device *usb_dev, uint usb_command,
        char *buf;
        int len;
 
-       buf = kmalloc(size, GFP_KERNEL);
+       buf = kmemdup(data, size, GFP_KERNEL);
        if (buf == NULL)
                return -ENOMEM;
 
-       memcpy(buf, data, size);
-
        len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
                        HID_REQ_SET_REPORT,
                        USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,