Skip to content

Commit

Permalink
HID: roccat: rename roccat_common functions to roccat_common2
Browse files Browse the repository at this point in the history
Did this to illustrate my understanding of the firmware generations:
Valo and Kone were 1st generation
Arvo was externaly developed and lies in the middle
All others until now are considered 2nd generation

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Stefan Achatz authored and Jiri Kosina committed Jun 28, 2012
1 parent 4ec141a commit 7392d73
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 67 deletions.
16 changes: 8 additions & 8 deletions drivers/hid/hid-roccat-arvo.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static ssize_t arvo_sysfs_show_mode_key(struct device *dev,
int retval;

mutex_lock(&arvo->arvo_lock);
retval = roccat_common_receive(usb_dev, ARVO_COMMAND_MODE_KEY,
retval = roccat_common2_receive(usb_dev, ARVO_COMMAND_MODE_KEY,
&temp_buf, sizeof(struct arvo_mode_key));
mutex_unlock(&arvo->arvo_lock);
if (retval)
Expand Down Expand Up @@ -67,7 +67,7 @@ static ssize_t arvo_sysfs_set_mode_key(struct device *dev,
temp_buf.state = state;

mutex_lock(&arvo->arvo_lock);
retval = roccat_common_send(usb_dev, ARVO_COMMAND_MODE_KEY,
retval = roccat_common2_send(usb_dev, ARVO_COMMAND_MODE_KEY,
&temp_buf, sizeof(struct arvo_mode_key));
mutex_unlock(&arvo->arvo_lock);
if (retval)
Expand All @@ -87,7 +87,7 @@ static ssize_t arvo_sysfs_show_key_mask(struct device *dev,
int retval;

mutex_lock(&arvo->arvo_lock);
retval = roccat_common_receive(usb_dev, ARVO_COMMAND_KEY_MASK,
retval = roccat_common2_receive(usb_dev, ARVO_COMMAND_KEY_MASK,
&temp_buf, sizeof(struct arvo_key_mask));
mutex_unlock(&arvo->arvo_lock);
if (retval)
Expand Down Expand Up @@ -115,7 +115,7 @@ static ssize_t arvo_sysfs_set_key_mask(struct device *dev,
temp_buf.key_mask = key_mask;

mutex_lock(&arvo->arvo_lock);
retval = roccat_common_send(usb_dev, ARVO_COMMAND_KEY_MASK,
retval = roccat_common2_send(usb_dev, ARVO_COMMAND_KEY_MASK,
&temp_buf, sizeof(struct arvo_key_mask));
mutex_unlock(&arvo->arvo_lock);
if (retval)
Expand All @@ -130,7 +130,7 @@ static int arvo_get_actual_profile(struct usb_device *usb_dev)
struct arvo_actual_profile temp_buf;
int retval;

retval = roccat_common_receive(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
retval = roccat_common2_receive(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
&temp_buf, sizeof(struct arvo_actual_profile));

if (retval)
Expand Down Expand Up @@ -170,7 +170,7 @@ static ssize_t arvo_sysfs_set_actual_profile(struct device *dev,
temp_buf.actual_profile = profile;

mutex_lock(&arvo->arvo_lock);
retval = roccat_common_send(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
retval = roccat_common2_send(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
&temp_buf, sizeof(struct arvo_actual_profile));
if (!retval) {
arvo->actual_profile = profile;
Expand All @@ -194,7 +194,7 @@ static ssize_t arvo_sysfs_write(struct file *fp,
return -EINVAL;

mutex_lock(&arvo->arvo_lock);
retval = roccat_common_send(usb_dev, command, buf, real_size);
retval = roccat_common2_send(usb_dev, command, buf, real_size);
mutex_unlock(&arvo->arvo_lock);

return (retval ? retval : real_size);
Expand All @@ -217,7 +217,7 @@ static ssize_t arvo_sysfs_read(struct file *fp,
return -EINVAL;

mutex_lock(&arvo->arvo_lock);
retval = roccat_common_receive(usb_dev, command, buf, real_size);
retval = roccat_common2_receive(usb_dev, command, buf, real_size);
mutex_unlock(&arvo->arvo_lock);

return (retval ? retval : real_size);
Expand Down
34 changes: 17 additions & 17 deletions drivers/hid/hid-roccat-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#include <linux/module.h>
#include "hid-roccat-common.h"

static inline uint16_t roccat_common_feature_report(uint8_t report_id)
static inline uint16_t roccat_common2_feature_report(uint8_t report_id)
{
return 0x300 | report_id;
}

int roccat_common_receive(struct usb_device *usb_dev, uint report_id,
int roccat_common2_receive(struct usb_device *usb_dev, uint report_id,
void *data, uint size)
{
char *buf;
Expand All @@ -34,16 +34,16 @@ int roccat_common_receive(struct usb_device *usb_dev, uint report_id,
len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
HID_REQ_GET_REPORT,
USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
roccat_common_feature_report(report_id),
roccat_common2_feature_report(report_id),
0, buf, size, USB_CTRL_SET_TIMEOUT);

memcpy(data, buf, size);
kfree(buf);
return ((len < 0) ? len : ((len != size) ? -EIO : 0));
}
EXPORT_SYMBOL_GPL(roccat_common_receive);
EXPORT_SYMBOL_GPL(roccat_common2_receive);

int roccat_common_send(struct usb_device *usb_dev, uint report_id,
int roccat_common2_send(struct usb_device *usb_dev, uint report_id,
void const *data, uint size)
{
char *buf;
Expand All @@ -56,31 +56,31 @@ int roccat_common_send(struct usb_device *usb_dev, uint report_id,
len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
HID_REQ_SET_REPORT,
USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
roccat_common_feature_report(report_id),
roccat_common2_feature_report(report_id),
0, buf, size, USB_CTRL_SET_TIMEOUT);

kfree(buf);
return ((len < 0) ? len : ((len != size) ? -EIO : 0));
}
EXPORT_SYMBOL_GPL(roccat_common_send);
EXPORT_SYMBOL_GPL(roccat_common2_send);

enum roccat_common_control_states {
enum roccat_common2_control_states {
ROCCAT_COMMON_CONTROL_STATUS_OVERLOAD = 0,
ROCCAT_COMMON_CONTROL_STATUS_OK = 1,
ROCCAT_COMMON_CONTROL_STATUS_INVALID = 2,
ROCCAT_COMMON_CONTROL_STATUS_WAIT = 3,
};

static int roccat_common_receive_control_status(struct usb_device *usb_dev)
static int roccat_common2_receive_control_status(struct usb_device *usb_dev)
{
int retval;
struct roccat_common_control control;
struct roccat_common2_control control;

do {
msleep(50);
retval = roccat_common_receive(usb_dev,
retval = roccat_common2_receive(usb_dev,
ROCCAT_COMMON_COMMAND_CONTROL,
&control, sizeof(struct roccat_common_control));
&control, sizeof(struct roccat_common2_control));

if (retval)
return retval;
Expand All @@ -98,7 +98,7 @@ static int roccat_common_receive_control_status(struct usb_device *usb_dev)
return -EINVAL;
default:
dev_err(&usb_dev->dev,
"roccat_common_receive_control_status: "
"roccat_common2_receive_control_status: "
"unknown response value 0x%x\n",
control.value);
return -EINVAL;
Expand All @@ -107,20 +107,20 @@ static int roccat_common_receive_control_status(struct usb_device *usb_dev)
} while (1);
}

int roccat_common_send_with_status(struct usb_device *usb_dev,
int roccat_common2_send_with_status(struct usb_device *usb_dev,
uint command, void const *buf, uint size)
{
int retval;

retval = roccat_common_send(usb_dev, command, buf, size);
retval = roccat_common2_send(usb_dev, command, buf, size);
if (retval)
return retval;

msleep(100);

return roccat_common_receive_control_status(usb_dev);
return roccat_common2_receive_control_status(usb_dev);
}
EXPORT_SYMBOL_GPL(roccat_common_send_with_status);
EXPORT_SYMBOL_GPL(roccat_common2_send_with_status);

MODULE_AUTHOR("Stefan Achatz");
MODULE_DESCRIPTION("USB Roccat common driver");
Expand Down
10 changes: 5 additions & 5 deletions drivers/hid/hid-roccat-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
#include <linux/usb.h>
#include <linux/types.h>

enum roccat_common_commands {
enum roccat_common2_commands {
ROCCAT_COMMON_COMMAND_CONTROL = 0x4,
};

struct roccat_common_control {
struct roccat_common2_control {
uint8_t command;
uint8_t value;
uint8_t request; /* always 0 on requesting write check */
} __packed;

int roccat_common_receive(struct usb_device *usb_dev, uint report_id,
int roccat_common2_receive(struct usb_device *usb_dev, uint report_id,
void *data, uint size);
int roccat_common_send(struct usb_device *usb_dev, uint report_id,
int roccat_common2_send(struct usb_device *usb_dev, uint report_id,
void const *data, uint size);
int roccat_common_send_with_status(struct usb_device *usb_dev,
int roccat_common2_send_with_status(struct usb_device *usb_dev,
uint command, void const *buf, uint size);

#endif
6 changes: 3 additions & 3 deletions drivers/hid/hid-roccat-isku.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void isku_profile_activated(struct isku_device *isku, uint new_profile)
static int isku_receive(struct usb_device *usb_dev, uint command,
void *buf, uint size)
{
return roccat_common_receive(usb_dev, command, buf, size);
return roccat_common2_receive(usb_dev, command, buf, size);
}

static int isku_get_actual_profile(struct usb_device *usb_dev)
Expand All @@ -56,7 +56,7 @@ static int isku_set_actual_profile(struct usb_device *usb_dev, int new_profile)
buf.command = ISKU_COMMAND_ACTUAL_PROFILE;
buf.size = sizeof(struct isku_actual_profile);
buf.actual_profile = new_profile;
return roccat_common_send_with_status(usb_dev,
return roccat_common2_send_with_status(usb_dev,
ISKU_COMMAND_ACTUAL_PROFILE, &buf,
sizeof(struct isku_actual_profile));
}
Expand Down Expand Up @@ -154,7 +154,7 @@ static ssize_t isku_sysfs_write(struct file *fp, struct kobject *kobj,
return -EINVAL;

mutex_lock(&isku->isku_lock);
retval = roccat_common_send_with_status(usb_dev, command,
retval = roccat_common2_send_with_status(usb_dev, command,
(void *)buf, real_size);
mutex_unlock(&isku->isku_lock);

Expand Down
24 changes: 12 additions & 12 deletions drivers/hid/hid-roccat-koneplus.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void koneplus_profile_activated(struct koneplus_device *koneplus,
static int koneplus_send_control(struct usb_device *usb_dev, uint value,
enum koneplus_control_requests request)
{
struct roccat_common_control control;
struct roccat_common2_control control;

if ((request == KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS ||
request == KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS) &&
Expand All @@ -50,15 +50,15 @@ static int koneplus_send_control(struct usb_device *usb_dev, uint value,
control.value = value;
control.request = request;

return roccat_common_send_with_status(usb_dev,
return roccat_common2_send_with_status(usb_dev,
ROCCAT_COMMON_COMMAND_CONTROL,
&control, sizeof(struct roccat_common_control));
&control, sizeof(struct roccat_common2_control));
}

static int koneplus_get_info(struct usb_device *usb_dev,
struct koneplus_info *buf)
{
return roccat_common_receive(usb_dev, KONEPLUS_COMMAND_INFO,
return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_INFO,
buf, sizeof(struct koneplus_info));
}

Expand All @@ -72,14 +72,14 @@ static int koneplus_get_profile_settings(struct usb_device *usb_dev,
if (retval)
return retval;

return roccat_common_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_SETTINGS,
return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_SETTINGS,
buf, sizeof(struct koneplus_profile_settings));
}

static int koneplus_set_profile_settings(struct usb_device *usb_dev,
struct koneplus_profile_settings const *settings)
{
return roccat_common_send_with_status(usb_dev,
return roccat_common2_send_with_status(usb_dev,
KONEPLUS_COMMAND_PROFILE_SETTINGS,
settings, sizeof(struct koneplus_profile_settings));
}
Expand All @@ -94,14 +94,14 @@ static int koneplus_get_profile_buttons(struct usb_device *usb_dev,
if (retval)
return retval;

return roccat_common_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_BUTTONS,
return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_BUTTONS,
buf, sizeof(struct koneplus_profile_buttons));
}

static int koneplus_set_profile_buttons(struct usb_device *usb_dev,
struct koneplus_profile_buttons const *buttons)
{
return roccat_common_send_with_status(usb_dev,
return roccat_common2_send_with_status(usb_dev,
KONEPLUS_COMMAND_PROFILE_BUTTONS,
buttons, sizeof(struct koneplus_profile_buttons));
}
Expand All @@ -112,7 +112,7 @@ static int koneplus_get_actual_profile(struct usb_device *usb_dev)
struct koneplus_actual_profile buf;
int retval;

retval = roccat_common_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE,
retval = roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE,
&buf, sizeof(struct koneplus_actual_profile));

return retval ? retval : buf.actual_profile;
Expand All @@ -127,7 +127,7 @@ static int koneplus_set_actual_profile(struct usb_device *usb_dev,
buf.size = sizeof(struct koneplus_actual_profile);
buf.actual_profile = new_profile;

return roccat_common_send_with_status(usb_dev,
return roccat_common2_send_with_status(usb_dev,
KONEPLUS_COMMAND_ACTUAL_PROFILE,
&buf, sizeof(struct koneplus_actual_profile));
}
Expand All @@ -149,7 +149,7 @@ static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj,
return -EINVAL;

mutex_lock(&koneplus->koneplus_lock);
retval = roccat_common_receive(usb_dev, command, buf, real_size);
retval = roccat_common2_receive(usb_dev, command, buf, real_size);
mutex_unlock(&koneplus->koneplus_lock);

if (retval)
Expand All @@ -172,7 +172,7 @@ static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj,
return -EINVAL;

mutex_lock(&koneplus->koneplus_lock);
retval = roccat_common_send_with_status(usb_dev, command,
retval = roccat_common2_send_with_status(usb_dev, command,
buf, real_size);
mutex_unlock(&koneplus->koneplus_lock);

Expand Down
Loading

0 comments on commit 7392d73

Please sign in to comment.