Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MISC: 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={...};

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bhumika Goyal and committed by
Greg Kroah-Hartman
57daedf8 e3b9c5ce

+4 -4
+1 -1
drivers/misc/ds1682.c
··· 173 173 return count; 174 174 } 175 175 176 - static struct bin_attribute ds1682_eeprom_attr = { 176 + static const struct bin_attribute ds1682_eeprom_attr = { 177 177 .attr = { 178 178 .name = "eeprom", 179 179 .mode = S_IRUGO | S_IWUSR,
+1 -1
drivers/misc/eeprom/eeprom.c
··· 114 114 return count; 115 115 } 116 116 117 - static struct bin_attribute eeprom_attr = { 117 + static const struct bin_attribute eeprom_attr = { 118 118 .attr = { 119 119 .name = "eeprom", 120 120 .mode = S_IRUGO,
+1 -1
drivers/misc/eeprom/max6875.c
··· 124 124 return count; 125 125 } 126 126 127 - static struct bin_attribute user_eeprom_attr = { 127 + static const struct bin_attribute user_eeprom_attr = { 128 128 .attr = { 129 129 .name = "eeprom", 130 130 .mode = S_IRUGO,
+1 -1
drivers/misc/pch_phub.c
··· 659 659 660 660 static DEVICE_ATTR(pch_mac, S_IRUGO | S_IWUSR, show_pch_mac, store_pch_mac); 661 661 662 - static struct bin_attribute pch_bin_attr = { 662 + static const struct bin_attribute pch_bin_attr = { 663 663 .attr = { 664 664 .name = "pch_firmware", 665 665 .mode = S_IRUGO | S_IWUSR,