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

i2c: slave-eeprom: 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: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

authored by

Thomas Weißschuh and committed by
Wolfram Sang
7fd9d28d 3cfe39b3

+4 -4
+4 -4
drivers/i2c/i2c-slave-eeprom.c
··· 91 91 } 92 92 93 93 static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj, 94 - struct bin_attribute *attr, char *buf, loff_t off, size_t count) 94 + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) 95 95 { 96 96 struct eeprom_data *eeprom; 97 97 unsigned long flags; ··· 106 106 } 107 107 108 108 static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kobj, 109 - struct bin_attribute *attr, char *buf, loff_t off, size_t count) 109 + const struct bin_attribute *attr, char *buf, loff_t off, size_t count) 110 110 { 111 111 struct eeprom_data *eeprom; 112 112 unsigned long flags; ··· 165 165 sysfs_bin_attr_init(&eeprom->bin); 166 166 eeprom->bin.attr.name = "slave-eeprom"; 167 167 eeprom->bin.attr.mode = S_IRUSR | S_IWUSR; 168 - eeprom->bin.read = i2c_slave_eeprom_bin_read; 169 - eeprom->bin.write = i2c_slave_eeprom_bin_write; 168 + eeprom->bin.read_new = i2c_slave_eeprom_bin_read; 169 + eeprom->bin.write_new = i2c_slave_eeprom_bin_write; 170 170 eeprom->bin.size = size; 171 171 172 172 ret = sysfs_create_bin_file(&client->dev.kobj, &eeprom->bin);