firmware: add const to bin_attribute structures
PATCH 1/1 firmware: add const to bin_attribute structures
Add const to bin_attribute structures as they are only passed to the functions sysfs_{remove/create}_bin_file. The arguments passed are of type const, so declare the structures to be const.
Done using Coccinelle.
@m disable optional_qualifier@
identifier s;
position p;
@@
static struct bin_attribute s@p={...};
@okay1@
position p;
identifier m.s;
@@
(sysfs_create_bin_file(...,&s@p,...)
|sysfs_remove_bin_file(...,&s@p,...)
)
@bad@
position p!={m.p,okay1.p};
identifier m.s;
@@
s@p
@change depends on !bad disable optional_qualifier@ identifier m.s;
@@
static
+const
struct bin_attribute s={...};
--- drivers/firmware/dell_rbu.c | 6 +++--- drivers/firmware/dmi-sysfs.c | 2 +- drivers/firmware/google/gsmi.c | 2 +- drivers/firmware/google/memconsole.c | 2 +- drivers/firmware/qemu_fw_cfg.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
drivers/firmware/dell_rbu.c +3 -3
@@ -675,18 +675,18 @@ static ssize_t write_rbu_packet_size(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute rbu_data_attr = { +static const struct bin_attribute rbu_data_attr = { .attr = {.name ="data" , .mode =0444 }, .read = read_rbu_data, }; -static struct bin_attribute rbu_image_type_attr = { +static const struct bin_attribute rbu_image_type_attr = { .attr = {.name ="image_type" , .mode =0644 }, .read = read_rbu_image_type, .write = write_rbu_image_type, }; -static struct bin_attribute rbu_packet_size_attr = { +static const struct bin_attribute rbu_packet_size_attr = { .attr = {.name ="packet_size" , .mode =0644 }, .read = read_rbu_packet_size, .write = write_rbu_packet_size,
drivers/firmware/dmi-sysfs.c +1 -1
@@ -440,7 +440,7 @@ static ssize_t dmi_sel_raw_read(struct file *filp, struct kobject *kobj,return find_dmi_entry (entry, dmi_sel_raw_read_helper, &state); } -static struct bin_attribute dmi_sel_raw_attr = { +static const struct bin_attribute dmi_sel_raw_attr = { .attr = {.name ="raw_event_log" , .mode =0400 }, .read = dmi_sel_raw_read, };
drivers/firmware/google/gsmi.c +1 -1
@@ -508,7 +508,7 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj, } -static struct bin_attribute eventlog_bin_attr = { +static const struct bin_attribute eventlog_bin_attr = { .attr = {.name ="append_to_eventlog" , .mode =0200 }, .write = eventlog_write, };
drivers/firmware/google/memconsole.c +1 -1
@@ -33,7 +33,7 @@ static ssize_t memconsole_read(struct file *filp, struct kobject *kobp,return memconsole_read_func (buf, pos, count); } -static struct bin_attribute memconsole_bin_attr = { +static const struct bin_attribute memconsole_bin_attr = { .attr = {.name ="log" , .mode =0444 }, .read = memconsole_read, };
drivers/firmware/qemu_fw_cfg.c +1 -1
@@ -343,7 +343,7 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute fw_cfg_sysfs_attr_raw = { +static const struct bin_attribute fw_cfg_sysfs_attr_raw = { .attr = { .name ="raw" , .mode =S_IRUSR }, .read = fw_cfg_sysfs_read_raw, };
Signature · 1 line
1.9.1
Quoted 28 lines · Bhumika Goyal
Add const to
bin_attributestructures as they are only passed to the functions sysfs_{remove/create}_bin_file. The arguments passed are of type const, so declare the structures to be const.Done using Coccinelle.
@m disable optional_qualifier@
identifier s;
position p;
@@
static structbin_attributes@p={...};@okay1@
position p;
identifier m.s;
@@
(sysfs_create_bin_file(...,&s@p,...)
|sysfs_remove_bin_file(...,&s@p,...)
)@bad@
position p!={m.p,okay1.p};
identifier m.s;
@@
s@p
Quoted 8 lines
@change depends on !bad disable optional_qualifier@ identifier m.s;
@@
static
+const
structbin_attributes={...};Signed-off-by Bhumika Goyal <[email protected]>
For qemu bits:
Feel free to merge.,
Quoted 88 lines
--- drivers/firmware/dell_rbu.c | 6 +++--- drivers/firmware/dmi-sysfs.c | 2 +- drivers/firmware/google/gsmi.c | 2 +- drivers/firmware/google/memconsole.c | 2 +- drivers/firmware/qemu_fw_cfg.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)drivers/firmware/dell_rbu.c +3
-3@@ -675,18 +675,18 @@ static ssize_t write_rbu_packet_size(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute rbu_data_attr = { +static const struct bin_attribute rbu_data_attr = { .attr = {.name ="data" , .mode =0444 }, .read = read_rbu_data, }; -static struct bin_attribute rbu_image_type_attr = { +static const struct bin_attribute rbu_image_type_attr = { .attr = {.name ="image_type" , .mode =0644 }, .read = read_rbu_image_type, .write = write_rbu_image_type, }; -static struct bin_attribute rbu_packet_size_attr = { +static const struct bin_attribute rbu_packet_size_attr = { .attr = {.name ="packet_size" , .mode =0644 }, .read = read_rbu_packet_size, .write = write_rbu_packet_size,drivers/firmware/dmi-sysfs.c +1
-1@@ -440,7 +440,7 @@ static ssize_t dmi_sel_raw_read(struct file *filp, struct kobject *kobj,return find_dmi_entry (entry, dmi_sel_raw_read_helper, &state); } -static struct bin_attribute dmi_sel_raw_attr = { +static const struct bin_attribute dmi_sel_raw_attr = { .attr = {.name ="raw_event_log" , .mode =0400 }, .read = dmi_sel_raw_read, };drivers/firmware/google/gsmi.c +1
-1@@ -508,7 +508,7 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj, } -static struct bin_attribute eventlog_bin_attr = { +static const struct bin_attribute eventlog_bin_attr = { .attr = {.name ="append_to_eventlog" , .mode =0200 }, .write = eventlog_write, };drivers/firmware/google/memconsole.c +1
-1@@ -33,7 +33,7 @@ static ssize_t memconsole_read(struct file *filp, struct kobject *kobp,return memconsole_read_func (buf, pos, count); } -static struct bin_attribute memconsole_bin_attr = { +static const struct bin_attribute memconsole_bin_attr = { .attr = {.name ="log" , .mode =0444 }, .read = memconsole_read, };drivers/firmware/qemu_fw_cfg.c +1
-1@@ -343,7 +343,7 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute fw_cfg_sysfs_attr_raw = { +static const struct bin_attribute fw_cfg_sysfs_attr_raw = { .attr = { .name ="raw" , .mode =S_IRUSR }, .read = fw_cfg_sysfs_read_raw, };Signature · 1 line
1.9.1