Skip to content

Commit 1cd9cea

Browse files
mwallemiquelraynal
authored andcommitted
mtd: core: provide unique name for nvmem device, take two
Commit c048b60 ("mtd: core: provide unique name for nvmem device") tries to give the nvmem device a unique name, but fails badly if the mtd device doesn't have a "struct device" associated with it, i.e. if CONFIG_MTD_PARTITIONED_MASTER is not set. This will result in the name "(null)-user-otp", which is not unique. It seems the best we can do is to use the compatible name together with a unique identifier added by the nvmem subsystem by using NVMEM_DEVID_AUTO. Fixes: c048b60 ("mtd: core: provide unique name for nvmem device") Cc: stable@vger.kernel.org Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230308082021.870459-1-michael@walle.cc
1 parent fe15c26 commit 1cd9cea

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/mtd/mtdcore.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,8 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd,
888888

889889
/* OTP nvmem will be registered on the physical device */
890890
config.dev = mtd->dev.parent;
891-
config.name = kasprintf(GFP_KERNEL, "%s-%s", dev_name(&mtd->dev), compatible);
892-
config.id = NVMEM_DEVID_NONE;
891+
config.name = compatible;
892+
config.id = NVMEM_DEVID_AUTO;
893893
config.owner = THIS_MODULE;
894894
config.type = NVMEM_TYPE_OTP;
895895
config.root_only = true;
@@ -905,7 +905,6 @@ static struct nvmem_device *mtd_otp_nvmem_register(struct mtd_info *mtd,
905905
nvmem = NULL;
906906

907907
of_node_put(np);
908-
kfree(config.name);
909908

910909
return nvmem;
911910
}

0 commit comments

Comments
 (0)