The at24 driver does not need to handle the ids by its own since the nvmem_core does the handling too. This lead into issues where the eeprom device is named: eeprom00. Fix the alias handling too since the devie would never be named as described in the alias, since we never told the nvmem-core to not add an additional id. Furthermore the devname can be static since the name gets later allocated by the dev_set_name(). Fix these three issues by just using the alias or the static "eeprom" sting and supply the correct NVMEM_DEVID_NONE or NVMEM_DEVID_AUTO to the core. Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx> --- v2: - no changes drivers/eeprom/at24.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c index 23cb0e1fbbc9..a5079279af35 100644 --- a/drivers/eeprom/at24.c +++ b/drivers/eeprom/at24.c @@ -371,7 +371,7 @@ static int at24_probe(struct device *dev) struct at24_data *at24; int err; unsigned i, num_addresses; - char *devname; + const char *devname; const char *alias; if (dev->platform_data) { @@ -425,16 +425,10 @@ static int at24_probe(struct device *dev) at24->num_addresses = num_addresses; alias = of_alias_get(dev->of_node); - if (alias) { - devname = xstrdup(alias); - } else { - err = cdev_find_free_index("eeprom"); - if (err < 0) { - dev_err(&client->dev, "no index found to name device\n"); - goto err_device_name; - } - devname = xasprintf("eeprom%d", err); - } + if (alias) + devname = alias; + else + devname = "eeprom"; writable = !(chip.flags & AT24_FLAG_READONLY); @@ -489,6 +483,7 @@ static int at24_probe(struct device *dev) at24->nvmem_config.stride = 1; at24->nvmem_config.word_size = 1; at24->nvmem_config.size = chip.byte_len; + at24->nvmem_config.id = alias ? NVMEM_DEVID_NONE : NVMEM_DEVID_AUTO; at24->nvmem = nvmem_register(&at24->nvmem_config); err = PTR_ERR_OR_ZERO(at24->nvmem); @@ -505,7 +500,6 @@ static int at24_probe(struct device *dev) if (gpio_is_valid(at24->wp_gpio)) gpio_free(at24->wp_gpio); kfree(at24->writebuf); -err_device_name: kfree(at24); err_out: dev_dbg(&client->dev, "probe error %d\n", err); -- 2.39.2