mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-10 08:23:59 +00:00
hid: roccat-pyra: 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> Cc: Stefan Achatz <erazor_de@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6853152689
commit
a749245168
1 changed files with 61 additions and 77 deletions
|
@ -156,7 +156,8 @@ PYRA_SYSFS_W(thingy, THINGY) \
|
||||||
PYRA_SYSFS_R(thingy, THINGY)
|
PYRA_SYSFS_R(thingy, THINGY)
|
||||||
|
|
||||||
#define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \
|
#define PYRA_BIN_ATTRIBUTE_RW(thingy, THINGY) \
|
||||||
{ \
|
PYRA_SYSFS_RW(thingy, THINGY); \
|
||||||
|
static struct bin_attribute bin_attr_##thingy = { \
|
||||||
.attr = { .name = #thingy, .mode = 0660 }, \
|
.attr = { .name = #thingy, .mode = 0660 }, \
|
||||||
.size = PYRA_SIZE_ ## THINGY, \
|
.size = PYRA_SIZE_ ## THINGY, \
|
||||||
.read = pyra_sysfs_read_ ## thingy, \
|
.read = pyra_sysfs_read_ ## thingy, \
|
||||||
|
@ -164,24 +165,25 @@ PYRA_SYSFS_R(thingy, THINGY)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \
|
#define PYRA_BIN_ATTRIBUTE_R(thingy, THINGY) \
|
||||||
{ \
|
PYRA_SYSFS_R(thingy, THINGY); \
|
||||||
|
static struct bin_attribute bin_attr_##thingy = { \
|
||||||
.attr = { .name = #thingy, .mode = 0440 }, \
|
.attr = { .name = #thingy, .mode = 0440 }, \
|
||||||
.size = PYRA_SIZE_ ## THINGY, \
|
.size = PYRA_SIZE_ ## THINGY, \
|
||||||
.read = pyra_sysfs_read_ ## thingy, \
|
.read = pyra_sysfs_read_ ## thingy, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \
|
#define PYRA_BIN_ATTRIBUTE_W(thingy, THINGY) \
|
||||||
{ \
|
PYRA_SYSFS_W(thingy, THINGY); \
|
||||||
|
static struct bin_attribute bin_attr_##thingy = { \
|
||||||
.attr = { .name = #thingy, .mode = 0220 }, \
|
.attr = { .name = #thingy, .mode = 0220 }, \
|
||||||
.size = PYRA_SIZE_ ## THINGY, \
|
.size = PYRA_SIZE_ ## THINGY, \
|
||||||
.write = pyra_sysfs_write_ ## thingy \
|
.write = pyra_sysfs_write_ ## thingy \
|
||||||
}
|
}
|
||||||
|
|
||||||
PYRA_SYSFS_W(control, CONTROL)
|
PYRA_BIN_ATTRIBUTE_W(control, CONTROL);
|
||||||
PYRA_SYSFS_RW(info, INFO)
|
PYRA_BIN_ATTRIBUTE_RW(info, INFO);
|
||||||
PYRA_SYSFS_RW(profile_settings, PROFILE_SETTINGS)
|
PYRA_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS);
|
||||||
PYRA_SYSFS_RW(profile_buttons, PROFILE_BUTTONS)
|
PYRA_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS);
|
||||||
PYRA_SYSFS_R(settings, SETTINGS)
|
|
||||||
|
|
||||||
static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp,
|
static ssize_t pyra_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,
|
||||||
|
@ -221,6 +223,25 @@ static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp,
|
||||||
PYRA_COMMAND_PROFILE_BUTTONS);
|
PYRA_COMMAND_PROFILE_BUTTONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PROFILE_ATTR(number) \
|
||||||
|
static struct bin_attribute bin_attr_profile##number##_settings = { \
|
||||||
|
.attr = { .name = "profile##number##_settings", .mode = 0440 }, \
|
||||||
|
.size = PYRA_SIZE_PROFILE_SETTINGS, \
|
||||||
|
.read = pyra_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 = PYRA_SIZE_PROFILE_BUTTONS, \
|
||||||
|
.read = pyra_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 pyra_sysfs_write_settings(struct file *fp,
|
static ssize_t pyra_sysfs_write_settings(struct file *fp,
|
||||||
struct kobject *kobj, struct bin_attribute *attr, char *buf,
|
struct kobject *kobj, struct bin_attribute *attr, char *buf,
|
||||||
loff_t off, size_t count)
|
loff_t off, size_t count)
|
||||||
|
@ -258,6 +279,11 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp,
|
||||||
return PYRA_SIZE_SETTINGS;
|
return PYRA_SIZE_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PYRA_SYSFS_R(settings, SETTINGS);
|
||||||
|
static struct bin_attribute bin_attr_settings =
|
||||||
|
__BIN_ATTR(settings, (S_IWUSR | S_IRUGO),
|
||||||
|
pyra_sysfs_read_settings, pyra_sysfs_write_settings,
|
||||||
|
PYRA_SIZE_SETTINGS);
|
||||||
|
|
||||||
static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
|
static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
|
@ -314,75 +340,34 @@ static struct attribute *pyra_attrs[] = {
|
||||||
&dev_attr_startup_profile.attr,
|
&dev_attr_startup_profile.attr,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
ATTRIBUTE_GROUPS(pyra);
|
|
||||||
|
|
||||||
static struct bin_attribute pyra_bin_attributes[] = {
|
static struct bin_attribute *pyra_bin_attributes[] = {
|
||||||
PYRA_BIN_ATTRIBUTE_W(control, CONTROL),
|
&bin_attr_control,
|
||||||
PYRA_BIN_ATTRIBUTE_RW(info, INFO),
|
&bin_attr_info,
|
||||||
PYRA_BIN_ATTRIBUTE_RW(profile_settings, PROFILE_SETTINGS),
|
&bin_attr_profile_settings,
|
||||||
PYRA_BIN_ATTRIBUTE_RW(profile_buttons, PROFILE_BUTTONS),
|
&bin_attr_profile_buttons,
|
||||||
PYRA_BIN_ATTRIBUTE_RW(settings, SETTINGS),
|
&bin_attr_settings,
|
||||||
{
|
&bin_attr_profile1_settings,
|
||||||
.attr = { .name = "profile1_settings", .mode = 0440 },
|
&bin_attr_profile2_settings,
|
||||||
.size = PYRA_SIZE_PROFILE_SETTINGS,
|
&bin_attr_profile3_settings,
|
||||||
.read = pyra_sysfs_read_profilex_settings,
|
&bin_attr_profile4_settings,
|
||||||
.private = &profile_numbers[0]
|
&bin_attr_profile5_settings,
|
||||||
},
|
&bin_attr_profile1_buttons,
|
||||||
{
|
&bin_attr_profile2_buttons,
|
||||||
.attr = { .name = "profile2_settings", .mode = 0440 },
|
&bin_attr_profile3_buttons,
|
||||||
.size = PYRA_SIZE_PROFILE_SETTINGS,
|
&bin_attr_profile4_buttons,
|
||||||
.read = pyra_sysfs_read_profilex_settings,
|
&bin_attr_profile5_buttons,
|
||||||
.private = &profile_numbers[1]
|
NULL,
|
||||||
},
|
};
|
||||||
{
|
|
||||||
.attr = { .name = "profile3_settings", .mode = 0440 },
|
static const struct attribute_group pyra_group = {
|
||||||
.size = PYRA_SIZE_PROFILE_SETTINGS,
|
.attrs = pyra_attrs,
|
||||||
.read = pyra_sysfs_read_profilex_settings,
|
.bin_attrs = pyra_bin_attributes,
|
||||||
.private = &profile_numbers[2]
|
};
|
||||||
},
|
|
||||||
{
|
static const struct attribute_group *pyra_groups[] = {
|
||||||
.attr = { .name = "profile4_settings", .mode = 0440 },
|
&pyra_group,
|
||||||
.size = PYRA_SIZE_PROFILE_SETTINGS,
|
NULL,
|
||||||
.read = pyra_sysfs_read_profilex_settings,
|
|
||||||
.private = &profile_numbers[3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile5_settings", .mode = 0440 },
|
|
||||||
.size = PYRA_SIZE_PROFILE_SETTINGS,
|
|
||||||
.read = pyra_sysfs_read_profilex_settings,
|
|
||||||
.private = &profile_numbers[4]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile1_buttons", .mode = 0440 },
|
|
||||||
.size = PYRA_SIZE_PROFILE_BUTTONS,
|
|
||||||
.read = pyra_sysfs_read_profilex_buttons,
|
|
||||||
.private = &profile_numbers[0]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile2_buttons", .mode = 0440 },
|
|
||||||
.size = PYRA_SIZE_PROFILE_BUTTONS,
|
|
||||||
.read = pyra_sysfs_read_profilex_buttons,
|
|
||||||
.private = &profile_numbers[1]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile3_buttons", .mode = 0440 },
|
|
||||||
.size = PYRA_SIZE_PROFILE_BUTTONS,
|
|
||||||
.read = pyra_sysfs_read_profilex_buttons,
|
|
||||||
.private = &profile_numbers[2]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile4_buttons", .mode = 0440 },
|
|
||||||
.size = PYRA_SIZE_PROFILE_BUTTONS,
|
|
||||||
.read = pyra_sysfs_read_profilex_buttons,
|
|
||||||
.private = &profile_numbers[3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile5_buttons", .mode = 0440 },
|
|
||||||
.size = PYRA_SIZE_PROFILE_BUTTONS,
|
|
||||||
.read = pyra_sysfs_read_profilex_buttons,
|
|
||||||
.private = &profile_numbers[4]
|
|
||||||
},
|
|
||||||
__ATTR_NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pyra_init_pyra_device_struct(struct usb_device *usb_dev,
|
static int pyra_init_pyra_device_struct(struct usb_device *usb_dev,
|
||||||
|
@ -605,7 +590,6 @@ static int __init pyra_init(void)
|
||||||
if (IS_ERR(pyra_class))
|
if (IS_ERR(pyra_class))
|
||||||
return PTR_ERR(pyra_class);
|
return PTR_ERR(pyra_class);
|
||||||
pyra_class->dev_groups = pyra_groups;
|
pyra_class->dev_groups = pyra_groups;
|
||||||
pyra_class->dev_bin_attrs = pyra_bin_attributes;
|
|
||||||
|
|
||||||
retval = hid_register_driver(&pyra_driver);
|
retval = hid_register_driver(&pyra_driver);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
|
Loading…
Add table
Reference in a new issue