rtc: add const to bin_attribute structures
PATCH 1/1 rtc: 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 or device_{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={...};
Same script was modified for device_{create/remove}_bin_file functions. Cross compiled drivers/rtc/rtc-tx4939.o file for mips architecture.
--- drivers/rtc/rtc-ds1305.c | 2 +- drivers/rtc/rtc-ds1343.c | 2 +- drivers/rtc/rtc-stk17ta8.c | 2 +- drivers/rtc/rtc-tx4939.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-ds1305.c +1 -1
@@ -558,7 +558,7 @@ static void msg_init(struct spi_message *m, struct spi_transfer *x,return (status <0 ) ? status : count; } -static struct bin_attribute nvram = { +static const struct bin_attribute nvram = { .attr.name ="nvram" , .attr.mode =S_IRUGO |S_IWUSR , .read = ds1305_nvram_read,
drivers/rtc/rtc-ds1343.c +1 -1
@@ -191,7 +191,7 @@ static ssize_t ds1343_nvram_read(struct file *filp, struct kobject *kobj, } -static struct bin_attribute nvram_attr = { +static const struct bin_attribute nvram_attr = { .attr.name ="nvram" , .attr.mode =S_IRUGO |S_IWUSR , .read = ds1343_nvram_read,
drivers/rtc/rtc-stk17ta8.c +1 -1
@@ -272,7 +272,7 @@ static ssize_t stk17ta8_nvram_write(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute stk17ta8_nvram_attr = { +static const struct bin_attribute stk17ta8_nvram_attr = { .attr = { .name ="nvram" , .mode =S_IRUGO |S_IWUSR ,
drivers/rtc/rtc-tx4939.c +1 -1
@@ -225,7 +225,7 @@ static ssize_t tx4939_rtc_nvram_write(struct file *filp, struct kobject *kobj,return count; } -static struct bin_attribute tx4939_rtc_nvram_attr = { +static const struct bin_attribute tx4939_rtc_nvram_attr = { .attr = { .name ="nvram" , .mode =S_IRUGO |S_IWUSR ,
Signature · 1 line
1.9.1