aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-roccat-kone.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-20 00:40:26 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-20 00:46:53 -0400
commit71b230af939ced7d67b65e7060e25d4cb18039ef (patch)
treee3185cd968b993e891b6fdf1ded959081f37cf4a /drivers/hid/hid-roccat-kone.c
parent8daf8c3aa6b4cad8ec5b286c75c3115d7fbf3fdf (diff)
hid: roccat-kone: 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>
Diffstat (limited to 'drivers/hid/hid-roccat-kone.c')
-rw-r--r--drivers/hid/hid-roccat-kone.c80
1 files changed, 34 insertions, 46 deletions
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
index d36267339e39..5eddf834c05c 100644
--- a/drivers/hid/hid-roccat-kone.c
+++ b/drivers/hid/hid-roccat-kone.c
@@ -324,6 +324,8 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj,
324 324
325 return sizeof(struct kone_settings); 325 return sizeof(struct kone_settings);
326} 326}
327static BIN_ATTR(settings, 0660, kone_sysfs_read_settings,
328 kone_sysfs_write_settings, sizeof(struct kone_settings));
327 329
328static ssize_t kone_sysfs_read_profilex(struct file *fp, 330static ssize_t kone_sysfs_read_profilex(struct file *fp,
329 struct kobject *kobj, struct bin_attribute *attr, 331 struct kobject *kobj, struct bin_attribute *attr,
@@ -378,6 +380,19 @@ static ssize_t kone_sysfs_write_profilex(struct file *fp,
378 380
379 return sizeof(struct kone_profile); 381 return sizeof(struct kone_profile);
380} 382}
383#define PROFILE_ATTR(number) \
384static struct bin_attribute bin_attr_profile##number = { \
385 .attr = { .name = "profile##number", .mode = 0660 }, \
386 .size = sizeof(struct kone_profile), \
387 .read = kone_sysfs_read_profilex, \
388 .write = kone_sysfs_write_profilex, \
389 .private = &profile_numbers[number], \
390};
391PROFILE_ATTR(1);
392PROFILE_ATTR(2);
393PROFILE_ATTR(3);
394PROFILE_ATTR(4);
395PROFILE_ATTR(5);
381 396
382static ssize_t kone_sysfs_show_actual_profile(struct device *dev, 397static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
383 struct device_attribute *attr, char *buf) 398 struct device_attribute *attr, char *buf)
@@ -616,51 +631,25 @@ static struct attribute *kone_attrs[] = {
616 &dev_attr_startup_profile.attr, 631 &dev_attr_startup_profile.attr,
617 NULL, 632 NULL,
618}; 633};
619ATTRIBUTE_GROUPS(kone); 634
620 635static struct bin_attribute *kone_bin_attributes[] = {
621static struct bin_attribute kone_bin_attributes[] = { 636 &bin_attr_settings,
622 { 637 &bin_attr_profile1,
623 .attr = { .name = "settings", .mode = 0660 }, 638 &bin_attr_profile2,
624 .size = sizeof(struct kone_settings), 639 &bin_attr_profile3,
625 .read = kone_sysfs_read_settings, 640 &bin_attr_profile4,
626 .write = kone_sysfs_write_settings 641 &bin_attr_profile5,
627 }, 642 NULL,
628 { 643};
629 .attr = { .name = "profile1", .mode = 0660 }, 644
630 .size = sizeof(struct kone_profile), 645static const struct attribute_group kone_group = {
631 .read = kone_sysfs_read_profilex, 646 .attrs = kone_attrs,
632 .write = kone_sysfs_write_profilex, 647 .bin_attrs = kone_bin_attributes,
633 .private = &profile_numbers[0] 648};
634 }, 649
635 { 650static const struct attribute_group *kone_groups[] = {
636 .attr = { .name = "profile2", .mode = 0660 }, 651 &kone_group,
637 .size = sizeof(struct kone_profile), 652 NULL,
638 .read = kone_sysfs_read_profilex,
639 .write = kone_sysfs_write_profilex,
640 .private = &profile_numbers[1]
641 },
642 {
643 .attr = { .name = "profile3", .mode = 0660 },
644 .size = sizeof(struct kone_profile),
645 .read = kone_sysfs_read_profilex,
646 .write = kone_sysfs_write_profilex,
647 .private = &profile_numbers[2]
648 },
649 {
650 .attr = { .name = "profile4", .mode = 0660 },
651 .size = sizeof(struct kone_profile),
652 .read = kone_sysfs_read_profilex,
653 .write = kone_sysfs_write_profilex,
654 .private = &profile_numbers[3]
655 },
656 {
657 .attr = { .name = "profile5", .mode = 0660 },
658 .size = sizeof(struct kone_profile),
659 .read = kone_sysfs_read_profilex,
660 .write = kone_sysfs_write_profilex,
661 .private = &profile_numbers[4]
662 },
663 __ATTR_NULL
664}; 653};
665 654
666static int kone_init_kone_device_struct(struct usb_device *usb_dev, 655static int kone_init_kone_device_struct(struct usb_device *usb_dev,
@@ -898,7 +887,6 @@ static int __init kone_init(void)
898 if (IS_ERR(kone_class)) 887 if (IS_ERR(kone_class))
899 return PTR_ERR(kone_class); 888 return PTR_ERR(kone_class);
900 kone_class->dev_groups = kone_groups; 889 kone_class->dev_groups = kone_groups;
901 kone_class->dev_bin_attrs = kone_bin_attributes;
902 890
903 retval = hid_register_driver(&kone_driver); 891 retval = hid_register_driver(&kone_driver);
904 if (retval) 892 if (retval)