summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-roccat-savu.c
diff options
context:
space:
mode:
authorStefan Achatz <erazor_de@users.sourceforge.net>2012-05-20 22:44:59 +0200
committerJiri Kosina <jkosina@suse.cz>2012-06-28 10:34:01 +0200
commit4728f2dc9f8e32ce898223fb863316ed7fa2d224 (patch)
treec8f2df1b448db340d556bf1be42b35cb96d4f0ab /drivers/hid/hid-roccat-savu.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-savu.c')
-rw-r--r--drivers/hid/hid-roccat-savu.c47
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 @@
static struct class *savu_class;
-static int savu_receive_control_status(struct usb_device *usb_dev)
-{
- int retval;
- struct savu_control control;
-
- do {
- msleep(50);
- retval = roccat_common_receive(usb_dev, SAVU_COMMAND_CONTROL,
- &control, sizeof(struct savu_control));
-
- if (retval)
- return retval;
-
- switch (control.value) {
- case SAVU_CONTROL_REQUEST_WRITE_CHECK_OK:
- return 0;
- case SAVU_CONTROL_REQUEST_WRITE_CHECK_WAIT:
- continue;
- case SAVU_CONTROL_REQUEST_WRITE_CHECK_INVALID:
- /* seems to be critical - replug necessary */
- case SAVU_CONTROL_REQUEST_WRITE_CHECK_OVERLOAD:
- return -EINVAL;
- default:
- hid_err(usb_dev, "savu_receive_control_status: "
- "unknown response value 0x%x\n",
- control.value);
- return -EINVAL;
- }
-
- } while (1);
-}
-
-static int savu_send(struct usb_device *usb_dev, uint command,
- void const *buf, uint size)
-{
- int retval;
-
- retval = roccat_common_send(usb_dev, command, buf, size);
- if (retval)
- return retval;
-
- return savu_receive_control_status(usb_dev);
-}
-
static ssize_t savu_sysfs_read(struct file *fp, struct kobject *kobj,
char *buf, loff_t off, size_t count,
size_t real_size, uint command)
@@ -108,7 +64,8 @@ static ssize_t savu_sysfs_write(struct file *fp, struct kobject *kobj,
return -EINVAL;
mutex_lock(&savu->savu_lock);
- retval = savu_send(usb_dev, command, (void *)buf, real_size);
+ retval = roccat_common_send_with_status(usb_dev, command,
+ (void *)buf, real_size);
mutex_unlock(&savu->savu_lock);
return retval ? retval : real_size;