Commit eb3156e0 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

hid: roccat-koneplus: 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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 08079548
...@@ -156,7 +156,8 @@ KONEPLUS_SYSFS_W(thingy, THINGY) \ ...@@ -156,7 +156,8 @@ KONEPLUS_SYSFS_W(thingy, THINGY) \
KONEPLUS_SYSFS_R(thingy, THINGY) KONEPLUS_SYSFS_R(thingy, THINGY)
#define KONEPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \ #define KONEPLUS_BIN_ATTRIBUTE_RW(thingy, THINGY) \
{ \ KONEPLUS_SYSFS_RW(thingy, THINGY); \
static struct bin_attribute bin_attr_##thingy = { \
.attr = { .name = #thingy, .mode = 0660 }, \ .attr = { .name = #thingy, .mode = 0660 }, \
.size = KONEPLUS_SIZE_ ## THINGY, \ .size = KONEPLUS_SIZE_ ## THINGY, \
.read = koneplus_sysfs_read_ ## thingy, \ .read = koneplus_sysfs_read_ ## thingy, \
...@@ -164,28 +165,29 @@ KONEPLUS_SYSFS_R(thingy, THINGY) ...@@ -164,28 +165,29 @@ KONEPLUS_SYSFS_R(thingy, THINGY)
} }
#define KONEPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \ #define KONEPLUS_BIN_ATTRIBUTE_R(thingy, THINGY) \
{ \ KONEPLUS_SYSFS_R(thingy, THINGY); \
static struct bin_attribute bin_attr_##thingy = { \
.attr = { .name = #thingy, .mode = 0440 }, \ .attr = { .name = #thingy, .mode = 0440 }, \
.size = KONEPLUS_SIZE_ ## THINGY, \ .size = KONEPLUS_SIZE_ ## THINGY, \
.read = koneplus_sysfs_read_ ## thingy, \ .read = koneplus_sysfs_read_ ## thingy, \
} }
#define KONEPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \ #define KONEPLUS_BIN_ATTRIBUTE_W(thingy, THINGY) \
{ \ KONEPLUS_SYSFS_W(thingy, THINGY); \
static struct bin_attribute bin_attr_##thingy = { \
.attr = { .name = #thingy, .mode = 0220 }, \ .attr = { .name = #thingy, .mode = 0220 }, \
.size = KONEPLUS_SIZE_ ## THINGY, \ .size = KONEPLUS_SIZE_ ## THINGY, \
.write = koneplus_sysfs_write_ ## thingy \ .write = koneplus_sysfs_write_ ## thingy \
} }
KONEPLUS_BIN_ATTRIBUTE_W(control, CONTROL);
KONEPLUS_SYSFS_W(control, CONTROL) KONEPLUS_BIN_ATTRIBUTE_W(talk, TALK);
KONEPLUS_SYSFS_RW(info, INFO) KONEPLUS_BIN_ATTRIBUTE_W(macro, MACRO);
KONEPLUS_SYSFS_W(talk, TALK) KONEPLUS_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE);
KONEPLUS_SYSFS_W(macro, MACRO) KONEPLUS_BIN_ATTRIBUTE_RW(info, INFO);
KONEPLUS_SYSFS_RW(sensor, SENSOR) KONEPLUS_BIN_ATTRIBUTE_RW(sensor, SENSOR);
KONEPLUS_SYSFS_RW(tcu, TCU) KONEPLUS_BIN_ATTRIBUTE_RW(tcu, TCU);
KONEPLUS_SYSFS_R(tcu_image, TCU_IMAGE) KONEPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS);
KONEPLUS_SYSFS_RW(profile_settings, PROFILE_SETTINGS) KONEPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS);
KONEPLUS_SYSFS_RW(profile_buttons, PROFILE_BUTTONS)
static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp, static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp,
struct kobject *kobj, struct bin_attribute *attr, char *buf, struct kobject *kobj, struct bin_attribute *attr, char *buf,
...@@ -225,6 +227,25 @@ static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp, ...@@ -225,6 +227,25 @@ static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp,
KONEPLUS_COMMAND_PROFILE_BUTTONS); KONEPLUS_COMMAND_PROFILE_BUTTONS);
} }
#define PROFILE_ATTR(number) \
static struct bin_attribute bin_attr_profile##number##_settings = { \
.attr = { .name = "profile##number##_settings", .mode = 0440 }, \
.size = KONEPLUS_SIZE_PROFILE_SETTINGS, \
.read = koneplus_sysfs_read_profilex_settings, \
.private = &profile_numbers[number-1], \
}; \
static struct bin_attribute bin_attr_profile##number##_buttons = { \
.attr = { .name = "profile##number##_buttons", .mode = 0440 }, \
.size = KONEPLUS_SIZE_PROFILE_BUTTONS, \
.read = koneplus_sysfs_read_profilex_buttons, \
.private = &profile_numbers[number-1], \
};
PROFILE_ATTR(1);
PROFILE_ATTR(2);
PROFILE_ATTR(3);
PROFILE_ATTR(4);
PROFILE_ATTR(5);
static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -308,79 +329,38 @@ static struct attribute *koneplus_attrs[] = { ...@@ -308,79 +329,38 @@ static struct attribute *koneplus_attrs[] = {
&dev_attr_firmware_version.attr, &dev_attr_firmware_version.attr,
NULL, NULL,
}; };
ATTRIBUTE_GROUPS(koneplus);
static struct bin_attribute *koneplus_bin_attributes[] = {
static struct bin_attribute koneplus_bin_attributes[] = { &bin_attr_control,
KONEPLUS_BIN_ATTRIBUTE_W(control, CONTROL), &bin_attr_talk,
KONEPLUS_BIN_ATTRIBUTE_RW(info, INFO), &bin_attr_macro,
KONEPLUS_BIN_ATTRIBUTE_W(talk, TALK), &bin_attr_tcu_image,
KONEPLUS_BIN_ATTRIBUTE_W(macro, MACRO), &bin_attr_info,
KONEPLUS_BIN_ATTRIBUTE_RW(sensor, SENSOR), &bin_attr_sensor,
KONEPLUS_BIN_ATTRIBUTE_RW(tcu, TCU), &bin_attr_tcu,
KONEPLUS_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE), &bin_attr_profile_settings,
KONEPLUS_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), &bin_attr_profile_buttons,
KONEPLUS_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), &bin_attr_profile1_settings,
{ &bin_attr_profile2_settings,
.attr = { .name = "profile1_settings", .mode = 0440 }, &bin_attr_profile3_settings,
.size = KONEPLUS_SIZE_PROFILE_SETTINGS, &bin_attr_profile4_settings,
.read = koneplus_sysfs_read_profilex_settings, &bin_attr_profile5_settings,
.private = &profile_numbers[0] &bin_attr_profile1_buttons,
}, &bin_attr_profile2_buttons,
{ &bin_attr_profile3_buttons,
.attr = { .name = "profile2_settings", .mode = 0440 }, &bin_attr_profile4_buttons,
.size = KONEPLUS_SIZE_PROFILE_SETTINGS, &bin_attr_profile5_buttons,
.read = koneplus_sysfs_read_profilex_settings, NULL,
.private = &profile_numbers[1] };
},
{ static const struct attribute_group koneplus_group = {
.attr = { .name = "profile3_settings", .mode = 0440 }, .attrs = koneplus_attrs,
.size = KONEPLUS_SIZE_PROFILE_SETTINGS, .bin_attrs = koneplus_bin_attributes,
.read = koneplus_sysfs_read_profilex_settings, };
.private = &profile_numbers[2]
}, static const struct attribute_group *koneplus_groups[] = {
{ &koneplus_group,
.attr = { .name = "profile4_settings", .mode = 0440 }, NULL,
.size = KONEPLUS_SIZE_PROFILE_SETTINGS,
.read = koneplus_sysfs_read_profilex_settings,
.private = &profile_numbers[3]
},
{
.attr = { .name = "profile5_settings", .mode = 0440 },
.size = KONEPLUS_SIZE_PROFILE_SETTINGS,
.read = koneplus_sysfs_read_profilex_settings,
.private = &profile_numbers[4]
},
{
.attr = { .name = "profile1_buttons", .mode = 0440 },
.size = KONEPLUS_SIZE_PROFILE_BUTTONS,
.read = koneplus_sysfs_read_profilex_buttons,
.private = &profile_numbers[0]
},
{
.attr = { .name = "profile2_buttons", .mode = 0440 },
.size = KONEPLUS_SIZE_PROFILE_BUTTONS,
.read = koneplus_sysfs_read_profilex_buttons,
.private = &profile_numbers[1]
},
{
.attr = { .name = "profile3_buttons", .mode = 0440 },
.size = KONEPLUS_SIZE_PROFILE_BUTTONS,
.read = koneplus_sysfs_read_profilex_buttons,
.private = &profile_numbers[2]
},
{
.attr = { .name = "profile4_buttons", .mode = 0440 },
.size = KONEPLUS_SIZE_PROFILE_BUTTONS,
.read = koneplus_sysfs_read_profilex_buttons,
.private = &profile_numbers[3]
},
{
.attr = { .name = "profile5_buttons", .mode = 0440 },
.size = KONEPLUS_SIZE_PROFILE_BUTTONS,
.read = koneplus_sysfs_read_profilex_buttons,
.private = &profile_numbers[4]
},
__ATTR_NULL
}; };
static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev,
...@@ -577,7 +557,6 @@ static int __init koneplus_init(void) ...@@ -577,7 +557,6 @@ static int __init koneplus_init(void)
if (IS_ERR(koneplus_class)) if (IS_ERR(koneplus_class))
return PTR_ERR(koneplus_class); return PTR_ERR(koneplus_class);
koneplus_class->dev_groups = koneplus_groups; koneplus_class->dev_groups = koneplus_groups;
koneplus_class->dev_bin_attrs = koneplus_bin_attributes;
retval = hid_register_driver(&koneplus_driver); retval = hid_register_driver(&koneplus_driver);
if (retval) if (retval)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment