hid: roccat-konepure: 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>
This commit is contained in:
Greg Kroah-Hartman 2013-08-19 21:50:28 -07:00
parent eb3156e0a6
commit 0f1947f356

View File

@ -94,7 +94,8 @@ KONEPURE_SYSFS_W(thingy, THINGY) \
KONEPURE_SYSFS_R(thingy, THINGY) KONEPURE_SYSFS_R(thingy, THINGY)
#define KONEPURE_BIN_ATTRIBUTE_RW(thingy, THINGY) \ #define KONEPURE_BIN_ATTRIBUTE_RW(thingy, THINGY) \
{ \ KONEPURE_SYSFS_RW(thingy, THINGY); \
static struct bin_attribute bin_attr_##thingy = { \
.attr = { .name = #thingy, .mode = 0660 }, \ .attr = { .name = #thingy, .mode = 0660 }, \
.size = KONEPURE_SIZE_ ## THINGY, \ .size = KONEPURE_SIZE_ ## THINGY, \
.read = konepure_sysfs_read_ ## thingy, \ .read = konepure_sysfs_read_ ## thingy, \
@ -102,44 +103,56 @@ KONEPURE_SYSFS_R(thingy, THINGY)
} }
#define KONEPURE_BIN_ATTRIBUTE_R(thingy, THINGY) \ #define KONEPURE_BIN_ATTRIBUTE_R(thingy, THINGY) \
{ \ KONEPURE_SYSFS_R(thingy, THINGY); \
static struct bin_attribute bin_attr_##thingy = { \
.attr = { .name = #thingy, .mode = 0440 }, \ .attr = { .name = #thingy, .mode = 0440 }, \
.size = KONEPURE_SIZE_ ## THINGY, \ .size = KONEPURE_SIZE_ ## THINGY, \
.read = konepure_sysfs_read_ ## thingy, \ .read = konepure_sysfs_read_ ## thingy, \
} }
#define KONEPURE_BIN_ATTRIBUTE_W(thingy, THINGY) \ #define KONEPURE_BIN_ATTRIBUTE_W(thingy, THINGY) \
{ \ KONEPURE_SYSFS_W(thingy, THINGY); \
static struct bin_attribute bin_attr_##thingy = { \
.attr = { .name = #thingy, .mode = 0220 }, \ .attr = { .name = #thingy, .mode = 0220 }, \
.size = KONEPURE_SIZE_ ## THINGY, \ .size = KONEPURE_SIZE_ ## THINGY, \
.write = konepure_sysfs_write_ ## thingy \ .write = konepure_sysfs_write_ ## thingy \
} }
KONEPURE_SYSFS_RW(actual_profile, ACTUAL_PROFILE) KONEPURE_BIN_ATTRIBUTE_RW(actual_profile, ACTUAL_PROFILE);
KONEPURE_SYSFS_W(control, CONTROL) KONEPURE_BIN_ATTRIBUTE_RW(info, INFO);
KONEPURE_SYSFS_RW(info, INFO) KONEPURE_BIN_ATTRIBUTE_RW(sensor, SENSOR);
KONEPURE_SYSFS_W(talk, TALK) KONEPURE_BIN_ATTRIBUTE_RW(tcu, TCU);
KONEPURE_SYSFS_W(macro, MACRO) KONEPURE_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS);
KONEPURE_SYSFS_RW(sensor, SENSOR) KONEPURE_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS);
KONEPURE_SYSFS_RW(tcu, TCU) KONEPURE_BIN_ATTRIBUTE_W(control, CONTROL);
KONEPURE_SYSFS_R(tcu_image, TCU_IMAGE) KONEPURE_BIN_ATTRIBUTE_W(talk, TALK);
KONEPURE_SYSFS_RW(profile_settings, PROFILE_SETTINGS) KONEPURE_BIN_ATTRIBUTE_W(macro, MACRO);
KONEPURE_SYSFS_RW(profile_buttons, PROFILE_BUTTONS) KONEPURE_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE);
static struct bin_attribute konepure_bin_attributes[] = { static struct bin_attribute *konepure_bin_attributes[] = {
KONEPURE_BIN_ATTRIBUTE_RW(actual_profile, ACTUAL_PROFILE), &bin_attr_actual_profile,
KONEPURE_BIN_ATTRIBUTE_W(control, CONTROL), &bin_attr_info,
KONEPURE_BIN_ATTRIBUTE_RW(info, INFO), &bin_attr_sensor,
KONEPURE_BIN_ATTRIBUTE_W(talk, TALK), &bin_attr_tcu,
KONEPURE_BIN_ATTRIBUTE_W(macro, MACRO), &bin_attr_profile_settings,
KONEPURE_BIN_ATTRIBUTE_RW(sensor, SENSOR), &bin_attr_profile_buttons,
KONEPURE_BIN_ATTRIBUTE_RW(tcu, TCU), &bin_attr_control,
KONEPURE_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE), &bin_attr_talk,
KONEPURE_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS), &bin_attr_macro,
KONEPURE_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS), &bin_attr_tcu_image,
__ATTR_NULL NULL,
}; };
static const struct attribute_group konepure_group = {
.bin_attrs = konepure_bin_attributes,
};
static const struct attribute_group *konepure_groups[] = {
&konepure_group,
NULL,
};
static int konepure_init_konepure_device_struct(struct usb_device *usb_dev, static int konepure_init_konepure_device_struct(struct usb_device *usb_dev,
struct konepure_device *konepure) struct konepure_device *konepure)
{ {
@ -282,7 +295,7 @@ static int __init konepure_init(void)
konepure_class = class_create(THIS_MODULE, "konepure"); konepure_class = class_create(THIS_MODULE, "konepure");
if (IS_ERR(konepure_class)) if (IS_ERR(konepure_class))
return PTR_ERR(konepure_class); return PTR_ERR(konepure_class);
konepure_class->dev_bin_attrs = konepure_bin_attributes; konepure_class->dev_groups = konepure_groups;
retval = hid_register_driver(&konepure_driver); retval = hid_register_driver(&konepure_driver);
if (retval) if (retval)