2 * Roccat common functions for device specific drivers
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
14 #include <linux/slab.h>
15 #include "hid-roccat-common.h"
17 int roccat_common_receive(struct usb_device *usb_dev, uint usb_command,
18 void *data, uint size)
23 buf = kmalloc(size, GFP_KERNEL);
27 len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
28 USB_REQ_CLEAR_FEATURE,
29 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
30 usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT);
32 memcpy(data, buf, size);
34 return ((len < 0) ? len : ((len != size) ? -EIO : 0));
36 EXPORT_SYMBOL_GPL(roccat_common_receive);
38 int roccat_common_send(struct usb_device *usb_dev, uint usb_command,
39 void const *data, uint size)
44 buf = kmalloc(size, GFP_KERNEL);
48 memcpy(buf, data, size);
50 len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
51 USB_REQ_SET_CONFIGURATION,
52 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
53 usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT);
56 return ((len < 0) ? len : ((len != size) ? -EIO : 0));
58 EXPORT_SYMBOL_GPL(roccat_common_send);
60 MODULE_AUTHOR("Stefan Achatz");
61 MODULE_DESCRIPTION("USB Roccat common driver");
62 MODULE_LICENSE("GPL v2");