aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-roccat-isku.c
diff options
context:
space:
mode:
authorStefan Achatz <erazor_de@users.sourceforge.net>2012-05-20 16:44:59 -0400
committerJiri Kosina <jkosina@suse.cz>2012-06-28 04:34:01 -0400
commit4728f2dc9f8e32ce898223fb863316ed7fa2d224 (patch)
treec8f2df1b448db340d556bf1be42b35cb96d4f0ab /drivers/hid/hid-roccat-isku.c
parent6a2a6390cf098b899a30146ef5c1fb85c9fefb3c (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-isku.c')
-rw-r--r--drivers/hid/hid-roccat-isku.c50
1 files changed, 4 insertions, 46 deletions
diff --git a/drivers/hid/hid-roccat-isku.c b/drivers/hid/hid-roccat-isku.c
index 0e4a0ab47142..20e7f84ee832 100644
--- a/drivers/hid/hid-roccat-isku.c
+++ b/drivers/hid/hid-roccat-isku.c
@@ -39,50 +39,6 @@ static int isku_receive(struct usb_device *usb_dev, uint command,
39 return roccat_common_receive(usb_dev, command, buf, size); 39 return roccat_common_receive(usb_dev, command, buf, size);
40} 40}
41 41
42static int isku_receive_control_status(struct usb_device *usb_dev)
43{
44 int retval;
45 struct isku_control control;
46
47 do {
48 msleep(50);
49 retval = isku_receive(usb_dev, ISKU_COMMAND_CONTROL,
50 &control, sizeof(struct isku_control));
51
52 if (retval)
53 return retval;
54
55 switch (control.value) {
56 case ISKU_CONTROL_VALUE_STATUS_OK:
57 return 0;
58 case ISKU_CONTROL_VALUE_STATUS_WAIT:
59 continue;
60 case ISKU_CONTROL_VALUE_STATUS_INVALID:
61 /* seems to be critical - replug necessary */
62 case ISKU_CONTROL_VALUE_STATUS_OVERLOAD:
63 return -EINVAL;
64 default:
65 hid_err(usb_dev, "isku_receive_control_status: "
66 "unknown response value 0x%x\n",
67 control.value);
68 return -EINVAL;
69 }
70
71 } while (1);
72}
73
74static int isku_send(struct usb_device *usb_dev, uint command,
75 void const *buf, uint size)
76{
77 int retval;
78
79 retval = roccat_common_send(usb_dev, command, buf, size);
80 if (retval)
81 return retval;
82
83 return isku_receive_control_status(usb_dev);
84}
85
86static int isku_get_actual_profile(struct usb_device *usb_dev) 42static int isku_get_actual_profile(struct usb_device *usb_dev)
87{ 43{
88 struct isku_actual_profile buf; 44 struct isku_actual_profile buf;
@@ -100,7 +56,8 @@ static int isku_set_actual_profile(struct usb_device *usb_dev, int new_profile)
100 buf.command = ISKU_COMMAND_ACTUAL_PROFILE; 56 buf.command = ISKU_COMMAND_ACTUAL_PROFILE;
101 buf.size = sizeof(struct isku_actual_profile); 57 buf.size = sizeof(struct isku_actual_profile);
102 buf.actual_profile = new_profile; 58 buf.actual_profile = new_profile;
103 return isku_send(usb_dev, ISKU_COMMAND_ACTUAL_PROFILE, &buf, 59 return roccat_common_send_with_status(usb_dev,
60 ISKU_COMMAND_ACTUAL_PROFILE, &buf,
104 sizeof(struct isku_actual_profile)); 61 sizeof(struct isku_actual_profile));
105} 62}
106 63
@@ -197,7 +154,8 @@ static ssize_t isku_sysfs_write(struct file *fp, struct kobject *kobj,
197 return -EINVAL; 154 return -EINVAL;
198 155
199 mutex_lock(&isku->isku_lock); 156 mutex_lock(&isku->isku_lock);
200 retval = isku_send(usb_dev, command, (void *)buf, real_size); 157 retval = roccat_common_send_with_status(usb_dev, command,
158 (void *)buf, real_size);
201 mutex_unlock(&isku->isku_lock); 159 mutex_unlock(&isku->isku_lock);
202 160
203 return retval ? retval : real_size; 161 return retval ? retval : real_size;