Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f1947f3 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eb3156e0
Loading
Loading
Loading
Loading
+40 −27
Original line number Diff line number Diff line
@@ -94,7 +94,8 @@ KONEPURE_SYSFS_W(thingy, THINGY) \
KONEPURE_SYSFS_R(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 }, \
	.size = KONEPURE_SIZE_ ## THINGY, \
	.read = konepure_sysfs_read_ ## thingy, \
@@ -102,44 +103,56 @@ KONEPURE_SYSFS_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 }, \
	.size = KONEPURE_SIZE_ ## THINGY, \
	.read = konepure_sysfs_read_ ## 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 }, \
	.size = KONEPURE_SIZE_ ## THINGY, \
	.write = konepure_sysfs_write_ ## thingy \
}

KONEPURE_SYSFS_RW(actual_profile, ACTUAL_PROFILE)
KONEPURE_SYSFS_W(control, CONTROL)
KONEPURE_SYSFS_RW(info, INFO)
KONEPURE_SYSFS_W(talk, TALK)
KONEPURE_SYSFS_W(macro, MACRO)
KONEPURE_SYSFS_RW(sensor, SENSOR)
KONEPURE_SYSFS_RW(tcu, TCU)
KONEPURE_SYSFS_R(tcu_image, TCU_IMAGE)
KONEPURE_SYSFS_RW(profile_settings, PROFILE_SETTINGS)
KONEPURE_SYSFS_RW(profile_buttons, PROFILE_BUTTONS)

static struct bin_attribute konepure_bin_attributes[] = {
	KONEPURE_BIN_ATTRIBUTE_RW(actual_profile, ACTUAL_PROFILE),
	KONEPURE_BIN_ATTRIBUTE_W(control, CONTROL),
	KONEPURE_BIN_ATTRIBUTE_RW(info, INFO),
	KONEPURE_BIN_ATTRIBUTE_W(talk, TALK),
	KONEPURE_BIN_ATTRIBUTE_W(macro, MACRO),
	KONEPURE_BIN_ATTRIBUTE_RW(sensor, SENSOR),
	KONEPURE_BIN_ATTRIBUTE_RW(tcu, TCU),
	KONEPURE_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE),
	KONEPURE_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS),
	KONEPURE_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS),
	__ATTR_NULL
KONEPURE_BIN_ATTRIBUTE_RW(actual_profile, ACTUAL_PROFILE);
KONEPURE_BIN_ATTRIBUTE_RW(info, INFO);
KONEPURE_BIN_ATTRIBUTE_RW(sensor, SENSOR);
KONEPURE_BIN_ATTRIBUTE_RW(tcu, TCU);
KONEPURE_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS);
KONEPURE_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS);
KONEPURE_BIN_ATTRIBUTE_W(control, CONTROL);
KONEPURE_BIN_ATTRIBUTE_W(talk, TALK);
KONEPURE_BIN_ATTRIBUTE_W(macro, MACRO);
KONEPURE_BIN_ATTRIBUTE_R(tcu_image, TCU_IMAGE);

static struct bin_attribute *konepure_bin_attributes[] = {
	&bin_attr_actual_profile,
	&bin_attr_info,
	&bin_attr_sensor,
	&bin_attr_tcu,
	&bin_attr_profile_settings,
	&bin_attr_profile_buttons,
	&bin_attr_control,
	&bin_attr_talk,
	&bin_attr_macro,
	&bin_attr_tcu_image,
	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,
		struct konepure_device *konepure)
{
@@ -282,7 +295,7 @@ static int __init konepure_init(void)
	konepure_class = class_create(THIS_MODULE, "konepure");
	if (IS_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);
	if (retval)