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

eeprom: ee1004: Let device core handle attribute eeprom

Instead of creating/removing the attribute ourselves, just declare the
attribute and let the device core handle it. This allows to simplify
the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/8a6c77f2-f84a-311b-c2b9-21798f690e4d@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Heiner Kallweit and committed by
Greg Kroah-Hartman
b63866ef 46ad0572

+9 -17
+9 -17
drivers/misc/eeprom/ee1004.c
··· 89 89 return status; 90 90 } 91 91 92 - static ssize_t ee1004_read(struct file *filp, struct kobject *kobj, 92 + static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, 93 93 struct bin_attribute *bin_attr, 94 94 char *buf, loff_t off, size_t count) 95 95 { ··· 160 160 return requested; 161 161 } 162 162 163 - static const struct bin_attribute eeprom_attr = { 164 - .attr = { 165 - .name = "eeprom", 166 - .mode = 0444, 167 - }, 168 - .size = EE1004_EEPROM_SIZE, 169 - .read = ee1004_read, 163 + static BIN_ATTR_RO(eeprom, EE1004_EEPROM_SIZE); 164 + 165 + static struct bin_attribute *ee1004_attrs[] = { 166 + &bin_attr_eeprom, 167 + NULL 170 168 }; 169 + 170 + BIN_ATTRIBUTE_GROUPS(ee1004); 171 171 172 172 static int ee1004_probe(struct i2c_client *client, 173 173 const struct i2c_device_id *id) ··· 222 222 ee1004_current_page); 223 223 mutex_unlock(&ee1004_bus_lock); 224 224 225 - /* Create the sysfs eeprom file */ 226 - err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr); 227 - if (err) 228 - goto err_clients_lock; 229 - 230 225 dev_info(&client->dev, 231 226 "%u byte EE1004-compliant SPD EEPROM, read-only\n", 232 227 EE1004_EEPROM_SIZE); ··· 232 237 233 238 return 0; 234 239 235 - err_clients_lock: 236 - mutex_lock(&ee1004_bus_lock); 237 240 err_clients: 238 241 if (--ee1004_dev_count == 0) { 239 242 for (cnr--; cnr >= 0; cnr--) { ··· 247 254 static int ee1004_remove(struct i2c_client *client) 248 255 { 249 256 int i; 250 - 251 - sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr); 252 257 253 258 /* Remove page select clients if this is the last device */ 254 259 mutex_lock(&ee1004_bus_lock); ··· 266 275 static struct i2c_driver ee1004_driver = { 267 276 .driver = { 268 277 .name = "ee1004", 278 + .dev_groups = ee1004_groups, 269 279 }, 270 280 .probe = ee1004_probe, 271 281 .remove = ee1004_remove,