aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-20 00:50:28 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-20 00:50:28 -0400
commit975b53cc903033b7ac30a37e06452394d6734018 (patch)
treeb33381b8a7c303602851474e1168787cf8dae03b
parent0f1947f3561e7e6df7164cf1e0f14f541ddc29bd (diff)
hid: roccat-kovaplus: convert class code to use bin_attrs in groups
Now that attribute groups support binary attributes, use them instead of the dev_bin_attrs field in struct class, as that is going away soon. Cc: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/hid/hid-roccat-kovaplus.c137
1 files changed, 54 insertions, 83 deletions
diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c
index ae630221f896..8a0f2993411f 100644
--- a/drivers/hid/hid-roccat-kovaplus.c
+++ b/drivers/hid/hid-roccat-kovaplus.c
@@ -197,31 +197,25 @@ KOVAPLUS_SYSFS_W(thingy, THINGY) \
197KOVAPLUS_SYSFS_R(thingy, THINGY) 197KOVAPLUS_SYSFS_R(thingy, THINGY)
198 198
199#define KOVAPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ 199#define KOVAPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \
200{ \ 200KOVAPLUS_SYSFS_RW(thingy, THINGY); \
201static struct bin_attribute bin_attr_##thingy = { \
201 .attr = { .name = #thingy, .mode = 0660 }, \ 202 .attr = { .name = #thingy, .mode = 0660 }, \
202 .size = KOVAPLUS_SIZE_ ## THINGY, \ 203 .size = KOVAPLUS_SIZE_ ## THINGY, \
203 .read = kovaplus_sysfs_read_ ## thingy, \ 204 .read = kovaplus_sysfs_read_ ## thingy, \
204 .write = kovaplus_sysfs_write_ ## thingy \ 205 .write = kovaplus_sysfs_write_ ## thingy \
205} 206}
206 207
207#define KOVAPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \
208{ \
209 .attr = { .name = #thingy, .mode = 0440 }, \
210 .size = KOVAPLUS_SIZE_ ## THINGY, \
211 .read = kovaplus_sysfs_read_ ## thingy, \
212}
213
214#define KOVAPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ 208#define KOVAPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \
215{ \ 209KOVAPLUS_SYSFS_W(thingy, THINGY); \
210static struct bin_attribute bin_attr_##thingy = { \
216 .attr = { .name = #thingy, .mode = 0220 }, \ 211 .attr = { .name = #thingy, .mode = 0220 }, \
217 .size = KOVAPLUS_SIZE_ ## THINGY, \ 212 .size = KOVAPLUS_SIZE_ ## THINGY, \
218 .write = kovaplus_sysfs_write_ ## thingy \ 213 .write = kovaplus_sysfs_write_ ## thingy \
219} 214}
220 215KOVAPLUS_BIN_ATTRIBUTE_W(control, CONTROL);
221KOVAPLUS_SYSFS_W(control, CONTROL) 216KOVAPLUS_BIN_ATTRIBUTE_RW(info, INFO);
222KOVAPLUS_SYSFS_RW(info, INFO) 217KOVAPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS);
223KOVAPLUS_SYSFS_RW(profile_settings, PROFILE_SETTINGS) 218KOVAPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS);
224KOVAPLUS_SYSFS_RW(profile_buttons, PROFILE_BUTTONS)
225 219
226static ssize_t kovaplus_sysfs_read_profilex_settings(struct file *fp, 220static ssize_t kovaplus_sysfs_read_profilex_settings(struct file *fp,
227 struct kobject *kobj, struct bin_attribute *attr, char *buf, 221 struct kobject *kobj, struct bin_attribute *attr, char *buf,
@@ -261,6 +255,25 @@ static ssize_t kovaplus_sysfs_read_profilex_buttons(struct file *fp,
261 KOVAPLUS_COMMAND_PROFILE_BUTTONS); 255 KOVAPLUS_COMMAND_PROFILE_BUTTONS);
262} 256}
263 257
258#define PROFILE_ATTR(number) \
259static struct bin_attribute bin_attr_profile##number##_settings = { \
260 .attr = { .name = "profile##number##_settings", .mode = 0440 }, \
261 .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, \
262 .read = kovaplus_sysfs_read_profilex_settings, \
263 .private = &profile_numbers[number-1], \
264}; \
265static struct bin_attribute bin_attr_profile##number##_buttons = { \
266 .attr = { .name = "profile##number##_buttons", .mode = 0440 }, \
267 .size = KOVAPLUS_SIZE_PROFILE_BUTTONS, \
268 .read = kovaplus_sysfs_read_profilex_buttons, \
269 .private = &profile_numbers[number-1], \
270};
271PROFILE_ATTR(1);
272PROFILE_ATTR(2);
273PROFILE_ATTR(3);
274PROFILE_ATTR(4);
275PROFILE_ATTR(5);
276
264static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev, 277static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev,
265 struct device_attribute *attr, char *buf) 278 struct device_attribute *attr, char *buf)
266{ 279{
@@ -372,74 +385,33 @@ static struct attribute *kovaplus_attrs[] = {
372 &dev_attr_actual_sensitivity_y.attr, 385 &dev_attr_actual_sensitivity_y.attr,
373 NULL, 386 NULL,
374}; 387};
375ATTRIBUTE_GROUPS(kovaplus); 388
376 389static struct bin_attribute *kovaplus_bin_attributes[] = {
377static struct bin_attribute kovaplus_bin_attributes[] = { 390 &bin_attr_control,
378 KOVAPLUS_BIN_ATTRIBUTE_W(control, CONTROL), 391 &bin_attr_info,
379 KOVAPLUS_BIN_ATTRIBUTE_RW(info, INFO), 392 &bin_attr_profile_settings,
380 KOVAPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), 393 &bin_attr_profile_buttons,
381 KOVAPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), 394 &bin_attr_profile1_settings,
382 { 395 &bin_attr_profile2_settings,
383 .attr = { .name = "profile1_settings", .mode = 0440 }, 396 &bin_attr_profile3_settings,
384 .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, 397 &bin_attr_profile4_settings,
385 .read = kovaplus_sysfs_read_profilex_settings, 398 &bin_attr_profile5_settings,
386 .private = &profile_numbers[0] 399 &bin_attr_profile1_buttons,
387 }, 400 &bin_attr_profile2_buttons,
388 { 401 &bin_attr_profile3_buttons,
389 .attr = { .name = "profile2_settings", .mode = 0440 }, 402 &bin_attr_profile4_buttons,
390 .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, 403 &bin_attr_profile5_buttons,
391 .read = kovaplus_sysfs_read_profilex_settings, 404 NULL,
392 .private = &profile_numbers[1] 405};
393 }, 406
394 { 407static const struct attribute_group kovaplus_group = {
395 .attr = { .name = "profile3_settings", .mode = 0440 }, 408 .attrs = kovaplus_attrs,
396 .size = KOVAPLUS_SIZE_PROFILE_SETTINGS, 409 .bin_attrs = kovaplus_bin_attributes,
397 .read = kovaplus_sysfs_read_profilex_settings, 410};
398 .private = &profile_numbers[2] 411
399 }, 412static const struct attribute_group *kovaplus_groups[] = {
400 { 413 &kovaplus_group,
401 .attr = { .name = "profile4_settings", .mode = 0440 }, 414 NULL,
402 .size = KOVAPLUS_SIZE_PROFILE_SETTINGS,
403 .read = kovaplus_sysfs_read_profilex_settings,
404 .private = &profile_numbers[3]
405 },
406 {
407 .attr = { .name = "profile5_settings", .mode = 0440 },
408 .size = KOVAPLUS_SIZE_PROFILE_SETTINGS,
409 .read = kovaplus_sysfs_read_profilex_settings,
410 .private = &profile_numbers[4]
411 },
412 {
413 .attr = { .name = "profile1_buttons", .mode = 0440 },
414 .size = KOVAPLUS_SIZE_PROFILE_BUTTONS,
415 .read = kovaplus_sysfs_read_profilex_buttons,
416 .private = &profile_numbers[0]
417 },
418 {
419 .attr = { .name = "profile2_buttons", .mode = 0440 },
420 .size = KOVAPLUS_SIZE_PROFILE_BUTTONS,
421 .read = kovaplus_sysfs_read_profilex_buttons,
422 .private = &profile_numbers[1]
423 },
424 {
425 .attr = { .name = "profile3_buttons", .mode = 0440 },
426 .size = KOVAPLUS_SIZE_PROFILE_BUTTONS,
427 .read = kovaplus_sysfs_read_profilex_buttons,
428 .private = &profile_numbers[2]
429 },
430 {
431 .attr = { .name = "profile4_buttons", .mode = 0440 },
432 .size = KOVAPLUS_SIZE_PROFILE_BUTTONS,
433 .read = kovaplus_sysfs_read_profilex_buttons,
434 .private = &profile_numbers[3]
435 },
436 {
437 .attr = { .name = "profile5_buttons", .mode = 0440 },
438 .size = KOVAPLUS_SIZE_PROFILE_BUTTONS,
439 .read = kovaplus_sysfs_read_profilex_buttons,
440 .private = &profile_numbers[4]
441 },
442 __ATTR_NULL
443}; 415};
444 416
445static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev, 417static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev,
@@ -668,7 +640,6 @@ static int __init kovaplus_init(void)
668 if (IS_ERR(kovaplus_class)) 640 if (IS_ERR(kovaplus_class))
669 return PTR_ERR(kovaplus_class); 641 return PTR_ERR(kovaplus_class);
670 kovaplus_class->dev_groups = kovaplus_groups; 642 kovaplus_class->dev_groups = kovaplus_groups;
671 kovaplus_class->dev_bin_attrs = kovaplus_bin_attributes;
672 643
673 retval = hid_register_driver(&kovaplus_driver); 644 retval = hid_register_driver(&kovaplus_driver);
674 if (retval) 645 if (retval)