aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-roccat-common.h
diff options
context:
space:
mode:
authorStefan Achatz <erazor_de@users.sourceforge.net>2013-10-28 13:52:05 -0400
committerJiri Kosina <jkosina@suse.cz>2013-10-30 09:17:31 -0400
commit71304f5a269abc25b9277744dfd6925f3e29e26a (patch)
tree1a6f6b7d9480a19f9a2a2d9bc7f6b6bc6dfe178f /drivers/hid/hid-roccat-common.h
parent14fc4290df2fb94a28f39dab9ed32feaa5527bef (diff)
HID: roccat: generalize some common code
Reduced some duplicate code by moving it to hid-roccat-common. 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-common.h')
-rw-r--r--drivers/hid/hid-roccat-common.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/hid/hid-roccat-common.h b/drivers/hid/hid-roccat-common.h
index a97746a63b70..eaa56eb7d5d1 100644
--- a/drivers/hid/hid-roccat-common.h
+++ b/drivers/hid/hid-roccat-common.h
@@ -32,4 +32,66 @@ int roccat_common2_send(struct usb_device *usb_dev, uint report_id,
32int roccat_common2_send_with_status(struct usb_device *usb_dev, 32int roccat_common2_send_with_status(struct usb_device *usb_dev,
33 uint command, void const *buf, uint size); 33 uint command, void const *buf, uint size);
34 34
35struct roccat_common2_device {
36 int roccat_claimed;
37 int chrdev_minor;
38 struct mutex lock;
39};
40
41int roccat_common2_device_init_struct(struct usb_device *usb_dev,
42 struct roccat_common2_device *dev);
43ssize_t roccat_common2_sysfs_read(struct file *fp, struct kobject *kobj,
44 char *buf, loff_t off, size_t count,
45 size_t real_size, uint command);
46ssize_t roccat_common2_sysfs_write(struct file *fp, struct kobject *kobj,
47 void const *buf, loff_t off, size_t count,
48 size_t real_size, uint command);
49
50#define ROCCAT_COMMON2_SYSFS_W(thingy, COMMAND, SIZE) \
51static ssize_t roccat_common2_sysfs_write_ ## thingy(struct file *fp, \
52 struct kobject *kobj, struct bin_attribute *attr, char *buf, \
53 loff_t off, size_t count) \
54{ \
55 return roccat_common2_sysfs_write(fp, kobj, buf, off, count, \
56 SIZE, COMMAND); \
57}
58
59#define ROCCAT_COMMON2_SYSFS_R(thingy, COMMAND, SIZE) \
60static ssize_t roccat_common2_sysfs_read_ ## thingy(struct file *fp, \
61 struct kobject *kobj, struct bin_attribute *attr, char *buf, \
62 loff_t off, size_t count) \
63{ \
64 return roccat_common2_sysfs_read(fp, kobj, buf, off, count, \
65 SIZE, COMMAND); \
66}
67
68#define ROCCAT_COMMON2_SYSFS_RW(thingy, COMMAND, SIZE) \
69ROCCAT_COMMON2_SYSFS_W(thingy, COMMAND, SIZE) \
70ROCCAT_COMMON2_SYSFS_R(thingy, COMMAND, SIZE)
71
72#define ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(thingy, COMMAND, SIZE) \
73ROCCAT_COMMON2_SYSFS_RW(thingy, COMMAND, SIZE); \
74static struct bin_attribute bin_attr_ ## thingy = { \
75 .attr = { .name = #thingy, .mode = 0660 }, \
76 .size = SIZE, \
77 .read = roccat_common2_sysfs_read_ ## thingy, \
78 .write = roccat_common2_sysfs_write_ ## thingy \
79}
80
81#define ROCCAT_COMMON2_BIN_ATTRIBUTE_R(thingy, COMMAND, SIZE) \
82ROCCAT_COMMON2_SYSFS_R(thingy, COMMAND, SIZE); \
83static struct bin_attribute bin_attr_ ## thingy = { \
84 .attr = { .name = #thingy, .mode = 0440 }, \
85 .size = SIZE, \
86 .read = roccat_common2_sysfs_read_ ## thingy, \
87}
88
89#define ROCCAT_COMMON2_BIN_ATTRIBUTE_W(thingy, COMMAND, SIZE) \
90ROCCAT_COMMON2_SYSFS_W(thingy, COMMAND, SIZE); \
91static struct bin_attribute bin_attr_ ## thingy = { \
92 .attr = { .name = #thingy, .mode = 0220 }, \
93 .size = SIZE, \
94 .write = roccat_common2_sysfs_write_ ## thingy \
95}
96
35#endif 97#endif