diff options
author | Stefan Achatz <erazor_de@users.sourceforge.net> | 2011-06-01 09:54:17 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-06-13 06:52:57 -0400 |
commit | 1edd5b42a6631b1b1f147e9018e309bde8d96a05 (patch) | |
tree | f40ddc82488de055948f634ee7c2caef8b8730f8 /drivers/hid/hid-roccat-kone.c | |
parent | 303f272c1f9f174146fc6c8fe9df614fa3e5825e (diff) |
HID: roccat: correction and cleanup of HID feature reports
Removed analog feature report enums and modified code in roccat_common
to reflect this. Non standard conform Kone got its own copy of the old
code. That helps extracting more generalizations for newer devices.
Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-roccat-kone.c')
-rw-r--r-- | drivers/hid/hid-roccat-kone.c | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index a57838d15267..7e29778fe7ab 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c | |||
@@ -37,6 +37,47 @@ | |||
37 | 37 | ||
38 | static uint profile_numbers[5] = {0, 1, 2, 3, 4}; | 38 | static uint profile_numbers[5] = {0, 1, 2, 3, 4}; |
39 | 39 | ||
40 | static int kone_receive(struct usb_device *usb_dev, uint usb_command, | ||
41 | void *data, uint size) | ||
42 | { | ||
43 | char *buf; | ||
44 | int len; | ||
45 | |||
46 | buf = kmalloc(size, GFP_KERNEL); | ||
47 | if (buf == NULL) | ||
48 | return -ENOMEM; | ||
49 | |||
50 | len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), | ||
51 | HID_REQ_GET_REPORT, | ||
52 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | ||
53 | usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT); | ||
54 | |||
55 | memcpy(data, buf, size); | ||
56 | kfree(buf); | ||
57 | return ((len < 0) ? len : ((len != size) ? -EIO : 0)); | ||
58 | } | ||
59 | |||
60 | static int kone_send(struct usb_device *usb_dev, uint usb_command, | ||
61 | void const *data, uint size) | ||
62 | { | ||
63 | char *buf; | ||
64 | int len; | ||
65 | |||
66 | buf = kmalloc(size, GFP_KERNEL); | ||
67 | if (buf == NULL) | ||
68 | return -ENOMEM; | ||
69 | |||
70 | memcpy(buf, data, size); | ||
71 | |||
72 | len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), | ||
73 | HID_REQ_SET_REPORT, | ||
74 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | ||
75 | usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT); | ||
76 | |||
77 | kfree(buf); | ||
78 | return ((len < 0) ? len : ((len != size) ? -EIO : 0)); | ||
79 | } | ||
80 | |||
40 | /* kone_class is used for creating sysfs attributes via roccat char device */ | 81 | /* kone_class is used for creating sysfs attributes via roccat char device */ |
41 | static struct class *kone_class; | 82 | static struct class *kone_class; |
42 | 83 | ||
@@ -68,7 +109,7 @@ static int kone_check_write(struct usb_device *usb_dev) | |||
68 | */ | 109 | */ |
69 | msleep(80); | 110 | msleep(80); |
70 | 111 | ||
71 | retval = roccat_common_receive(usb_dev, | 112 | retval = kone_receive(usb_dev, |
72 | kone_command_confirm_write, &data, 1); | 113 | kone_command_confirm_write, &data, 1); |
73 | if (retval) | 114 | if (retval) |
74 | return retval; | 115 | return retval; |
@@ -96,7 +137,7 @@ static int kone_check_write(struct usb_device *usb_dev) | |||
96 | static int kone_get_settings(struct usb_device *usb_dev, | 137 | static int kone_get_settings(struct usb_device *usb_dev, |
97 | struct kone_settings *buf) | 138 | struct kone_settings *buf) |
98 | { | 139 | { |
99 | return roccat_common_receive(usb_dev, kone_command_settings, buf, | 140 | return kone_receive(usb_dev, kone_command_settings, buf, |
100 | sizeof(struct kone_settings)); | 141 | sizeof(struct kone_settings)); |
101 | } | 142 | } |
102 | 143 | ||
@@ -109,7 +150,7 @@ static int kone_set_settings(struct usb_device *usb_dev, | |||
109 | struct kone_settings const *settings) | 150 | struct kone_settings const *settings) |
110 | { | 151 | { |
111 | int retval; | 152 | int retval; |
112 | retval = roccat_common_send(usb_dev, kone_command_settings, | 153 | retval = kone_send(usb_dev, kone_command_settings, |
113 | settings, sizeof(struct kone_settings)); | 154 | settings, sizeof(struct kone_settings)); |
114 | if (retval) | 155 | if (retval) |
115 | return retval; | 156 | return retval; |
@@ -182,7 +223,7 @@ static int kone_get_weight(struct usb_device *usb_dev, int *result) | |||
182 | int retval; | 223 | int retval; |
183 | uint8_t data; | 224 | uint8_t data; |
184 | 225 | ||
185 | retval = roccat_common_receive(usb_dev, kone_command_weight, &data, 1); | 226 | retval = kone_receive(usb_dev, kone_command_weight, &data, 1); |
186 | 227 | ||
187 | if (retval) | 228 | if (retval) |
188 | return retval; | 229 | return retval; |
@@ -201,7 +242,7 @@ static int kone_get_firmware_version(struct usb_device *usb_dev, int *result) | |||
201 | int retval; | 242 | int retval; |
202 | uint16_t data; | 243 | uint16_t data; |
203 | 244 | ||
204 | retval = roccat_common_receive(usb_dev, kone_command_firmware_version, | 245 | retval = kone_receive(usb_dev, kone_command_firmware_version, |
205 | &data, 2); | 246 | &data, 2); |
206 | if (retval) | 247 | if (retval) |
207 | return retval; | 248 | return retval; |
@@ -384,7 +425,7 @@ static int kone_tcu_command(struct usb_device *usb_dev, int number) | |||
384 | { | 425 | { |
385 | unsigned char value; | 426 | unsigned char value; |
386 | value = number; | 427 | value = number; |
387 | return roccat_common_send(usb_dev, kone_command_calibrate, &value, 1); | 428 | return kone_send(usb_dev, kone_command_calibrate, &value, 1); |
388 | } | 429 | } |
389 | 430 | ||
390 | /* | 431 | /* |