mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-01 03:54:02 +00:00
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>
This commit is contained in:
parent
8daf8c3aa6
commit
71b230af93
1 changed files with 33 additions and 45 deletions
|
@ -324,6 +324,8 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj,
|
||||||
|
|
||||||
return sizeof(struct kone_settings);
|
return sizeof(struct kone_settings);
|
||||||
}
|
}
|
||||||
|
static BIN_ATTR(settings, 0660, kone_sysfs_read_settings,
|
||||||
|
kone_sysfs_write_settings, sizeof(struct kone_settings));
|
||||||
|
|
||||||
static ssize_t kone_sysfs_read_profilex(struct file *fp,
|
static ssize_t kone_sysfs_read_profilex(struct file *fp,
|
||||||
struct kobject *kobj, struct bin_attribute *attr,
|
struct kobject *kobj, struct bin_attribute *attr,
|
||||||
|
@ -378,6 +380,19 @@ static ssize_t kone_sysfs_write_profilex(struct file *fp,
|
||||||
|
|
||||||
return sizeof(struct kone_profile);
|
return sizeof(struct kone_profile);
|
||||||
}
|
}
|
||||||
|
#define PROFILE_ATTR(number) \
|
||||||
|
static struct bin_attribute bin_attr_profile##number = { \
|
||||||
|
.attr = { .name = "profile##number", .mode = 0660 }, \
|
||||||
|
.size = sizeof(struct kone_profile), \
|
||||||
|
.read = kone_sysfs_read_profilex, \
|
||||||
|
.write = kone_sysfs_write_profilex, \
|
||||||
|
.private = &profile_numbers[number], \
|
||||||
|
};
|
||||||
|
PROFILE_ATTR(1);
|
||||||
|
PROFILE_ATTR(2);
|
||||||
|
PROFILE_ATTR(3);
|
||||||
|
PROFILE_ATTR(4);
|
||||||
|
PROFILE_ATTR(5);
|
||||||
|
|
||||||
static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
|
static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
|
@ -616,51 +631,25 @@ static struct attribute *kone_attrs[] = {
|
||||||
&dev_attr_startup_profile.attr,
|
&dev_attr_startup_profile.attr,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
ATTRIBUTE_GROUPS(kone);
|
|
||||||
|
|
||||||
static struct bin_attribute kone_bin_attributes[] = {
|
static struct bin_attribute *kone_bin_attributes[] = {
|
||||||
{
|
&bin_attr_settings,
|
||||||
.attr = { .name = "settings", .mode = 0660 },
|
&bin_attr_profile1,
|
||||||
.size = sizeof(struct kone_settings),
|
&bin_attr_profile2,
|
||||||
.read = kone_sysfs_read_settings,
|
&bin_attr_profile3,
|
||||||
.write = kone_sysfs_write_settings
|
&bin_attr_profile4,
|
||||||
},
|
&bin_attr_profile5,
|
||||||
{
|
NULL,
|
||||||
.attr = { .name = "profile1", .mode = 0660 },
|
};
|
||||||
.size = sizeof(struct kone_profile),
|
|
||||||
.read = kone_sysfs_read_profilex,
|
static const struct attribute_group kone_group = {
|
||||||
.write = kone_sysfs_write_profilex,
|
.attrs = kone_attrs,
|
||||||
.private = &profile_numbers[0]
|
.bin_attrs = kone_bin_attributes,
|
||||||
},
|
};
|
||||||
{
|
|
||||||
.attr = { .name = "profile2", .mode = 0660 },
|
static const struct attribute_group *kone_groups[] = {
|
||||||
.size = sizeof(struct kone_profile),
|
&kone_group,
|
||||||
.read = kone_sysfs_read_profilex,
|
NULL,
|
||||||
.write = kone_sysfs_write_profilex,
|
|
||||||
.private = &profile_numbers[1]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile3", .mode = 0660 },
|
|
||||||
.size = sizeof(struct kone_profile),
|
|
||||||
.read = kone_sysfs_read_profilex,
|
|
||||||
.write = kone_sysfs_write_profilex,
|
|
||||||
.private = &profile_numbers[2]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile4", .mode = 0660 },
|
|
||||||
.size = sizeof(struct kone_profile),
|
|
||||||
.read = kone_sysfs_read_profilex,
|
|
||||||
.write = kone_sysfs_write_profilex,
|
|
||||||
.private = &profile_numbers[3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.attr = { .name = "profile5", .mode = 0660 },
|
|
||||||
.size = sizeof(struct kone_profile),
|
|
||||||
.read = kone_sysfs_read_profilex,
|
|
||||||
.write = kone_sysfs_write_profilex,
|
|
||||||
.private = &profile_numbers[4]
|
|
||||||
},
|
|
||||||
__ATTR_NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int kone_init_kone_device_struct(struct usb_device *usb_dev,
|
static int kone_init_kone_device_struct(struct usb_device *usb_dev,
|
||||||
|
@ -898,7 +887,6 @@ static int __init kone_init(void)
|
||||||
if (IS_ERR(kone_class))
|
if (IS_ERR(kone_class))
|
||||||
return PTR_ERR(kone_class);
|
return PTR_ERR(kone_class);
|
||||||
kone_class->dev_groups = kone_groups;
|
kone_class->dev_groups = kone_groups;
|
||||||
kone_class->dev_bin_attrs = kone_bin_attributes;
|
|
||||||
|
|
||||||
retval = hid_register_driver(&kone_driver);
|
retval = hid_register_driver(&kone_driver);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
|
Loading…
Add table
Reference in a new issue