Commit 68489bad authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Jiri Kosina
Browse files

HID: roccat: arvo: constify 'struct bin_attribute'



The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 66f58ab4
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -224,23 +224,23 @@ static ssize_t arvo_sysfs_read(struct file *fp,
}

static ssize_t arvo_sysfs_write_button(struct file *fp,
		struct kobject *kobj, struct bin_attribute *attr, char *buf,
		loff_t off, size_t count)
		struct kobject *kobj, const struct bin_attribute *attr,
		char *buf, loff_t off, size_t count)
{
	return arvo_sysfs_write(fp, kobj, buf, off, count,
			sizeof(struct arvo_button), ARVO_COMMAND_BUTTON);
}
static BIN_ATTR(button, 0220, NULL, arvo_sysfs_write_button,
static const BIN_ATTR(button, 0220, NULL, arvo_sysfs_write_button,
		      sizeof(struct arvo_button));

static ssize_t arvo_sysfs_read_info(struct file *fp,
		struct kobject *kobj, struct bin_attribute *attr, char *buf,
		loff_t off, size_t count)
		struct kobject *kobj, const struct bin_attribute *attr,
		char *buf, loff_t off, size_t count)
{
	return arvo_sysfs_read(fp, kobj, buf, off, count,
			sizeof(struct arvo_info), ARVO_COMMAND_INFO);
}
static BIN_ATTR(info, 0440, arvo_sysfs_read_info, NULL,
static const BIN_ATTR(info, 0440, arvo_sysfs_read_info, NULL,
		      sizeof(struct arvo_info));

static struct attribute *arvo_attrs[] = {
@@ -250,7 +250,7 @@ static struct attribute *arvo_attrs[] = {
	NULL,
};

static struct bin_attribute *arvo_bin_attributes[] = {
static const struct bin_attribute *const arvo_bin_attributes[] = {
	&bin_attr_button,
	&bin_attr_info,
	NULL,
@@ -258,7 +258,7 @@ static struct bin_attribute *arvo_bin_attributes[] = {

static const struct attribute_group arvo_group = {
	.attrs = arvo_attrs,
	.bin_attrs = arvo_bin_attributes,
	.bin_attrs_new = arvo_bin_attributes,
};

static const struct attribute_group *arvo_groups[] = {