diff options
author | Stefan Achatz <erazor_de@users.sourceforge.net> | 2012-05-20 16:44:59 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2012-06-28 04:34:01 -0400 |
commit | 4728f2dc9f8e32ce898223fb863316ed7fa2d224 (patch) | |
tree | c8f2df1b448db340d556bf1be42b35cb96d4f0ab /drivers/hid/hid-roccat-savu.c | |
parent | 6a2a6390cf098b899a30146ef5c1fb85c9fefb3c (diff) |
HID: roccat: move functionality to roccat-common
Reduced code duplication by moving functions from individual drivers
to roccat-common module.
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-savu.c')
-rw-r--r-- | drivers/hid/hid-roccat-savu.c | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/drivers/hid/hid-roccat-savu.c b/drivers/hid/hid-roccat-savu.c index d6c82d57408a..19f9c47fc020 100644 --- a/drivers/hid/hid-roccat-savu.c +++ b/drivers/hid/hid-roccat-savu.c | |||
@@ -27,50 +27,6 @@ | |||
27 | 27 | ||
28 | static struct class *savu_class; | 28 | static struct class *savu_class; |
29 | 29 | ||
30 | static int savu_receive_control_status(struct usb_device *usb_dev) | ||
31 | { | ||
32 | int retval; | ||
33 | struct savu_control control; | ||
34 | |||
35 | do { | ||
36 | msleep(50); | ||
37 | retval = roccat_common_receive(usb_dev, SAVU_COMMAND_CONTROL, | ||
38 | &control, sizeof(struct savu_control)); | ||
39 | |||
40 | if (retval) | ||
41 | return retval; | ||
42 | |||
43 | switch (control.value) { | ||
44 | case SAVU_CONTROL_REQUEST_WRITE_CHECK_OK: | ||
45 | return 0; | ||
46 | case SAVU_CONTROL_REQUEST_WRITE_CHECK_WAIT: | ||
47 | continue; | ||
48 | case SAVU_CONTROL_REQUEST_WRITE_CHECK_INVALID: | ||
49 | /* seems to be critical - replug necessary */ | ||
50 | case SAVU_CONTROL_REQUEST_WRITE_CHECK_OVERLOAD: | ||
51 | return -EINVAL; | ||
52 | default: | ||
53 | hid_err(usb_dev, "savu_receive_control_status: " | ||
54 | "unknown response value 0x%x\n", | ||
55 | control.value); | ||
56 | return -EINVAL; | ||
57 | } | ||
58 | |||
59 | } while (1); | ||
60 | } | ||
61 | |||
62 | static int savu_send(struct usb_device *usb_dev, uint command, | ||
63 | void const *buf, uint size) | ||
64 | { | ||
65 | int retval; | ||
66 | |||
67 | retval = roccat_common_send(usb_dev, command, buf, size); | ||
68 | if (retval) | ||
69 | return retval; | ||
70 | |||
71 | return savu_receive_control_status(usb_dev); | ||
72 | } | ||
73 | |||
74 | static ssize_t savu_sysfs_read(struct file *fp, struct kobject *kobj, | 30 | static ssize_t savu_sysfs_read(struct file *fp, struct kobject *kobj, |
75 | char *buf, loff_t off, size_t count, | 31 | char *buf, loff_t off, size_t count, |
76 | size_t real_size, uint command) | 32 | size_t real_size, uint command) |
@@ -108,7 +64,8 @@ static ssize_t savu_sysfs_write(struct file *fp, struct kobject *kobj, | |||
108 | return -EINVAL; | 64 | return -EINVAL; |
109 | 65 | ||
110 | mutex_lock(&savu->savu_lock); | 66 | mutex_lock(&savu->savu_lock); |
111 | retval = savu_send(usb_dev, command, (void *)buf, real_size); | 67 | retval = roccat_common_send_with_status(usb_dev, command, |
68 | (void *)buf, real_size); | ||
112 | mutex_unlock(&savu->savu_lock); | 69 | mutex_unlock(&savu->savu_lock); |
113 | 70 | ||
114 | return retval ? retval : real_size; | 71 | return retval ? retval : real_size; |