424-v6.4-0001-mtd-core-provide-unique-name-for-nvmem-device-take-t.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From 1cd9ceaa5282ff10ea20a7fbadde5a476a1cc99e Mon Sep 17 00:00:00 2001
  2. From: Michael Walle <[email protected]>
  3. Date: Wed, 8 Mar 2023 09:20:18 +0100
  4. Subject: [PATCH] mtd: core: provide unique name for nvmem device, take two
  5. Commit c048b60d39e1 ("mtd: core: provide unique name for nvmem device")
  6. tries to give the nvmem device a unique name, but fails badly if the mtd
  7. device doesn't have a "struct device" associated with it, i.e. if
  8. CONFIG_MTD_PARTITIONED_MASTER is not set. This will result in the name
  9. "(null)-user-otp", which is not unique. It seems the best we can do is
  10. to use the compatible name together with a unique identifier added by
  11. the nvmem subsystem by using NVMEM_DEVID_AUTO.
  12. Fixes: c048b60d39e1 ("mtd: core: provide unique name for nvmem device")
  13. Cc: [email protected]
  14. Signed-off-by: Michael Walle <[email protected]>
  15. Signed-off-by: Miquel Raynal <[email protected]>
  16. Link: https://lore.kernel.org/linux-mtd/[email protected]
  17. ---
  18. drivers/mtd/mtdcore.c | 5 ++---
  19. 1 file changed, 2 insertions(+), 3 deletions(-)
  20. --- a/drivers/mtd/mtdcore.c
  21. +++ b/drivers/mtd/mtdcore.c
  22. @@ -895,8 +895,8 @@ static struct nvmem_device *mtd_otp_nvme
  23. /* OTP nvmem will be registered on the physical device */
  24. config.dev = mtd->dev.parent;
  25. - config.name = kasprintf(GFP_KERNEL, "%s-%s", dev_name(&mtd->dev), compatible);
  26. - config.id = NVMEM_DEVID_NONE;
  27. + config.name = compatible;
  28. + config.id = NVMEM_DEVID_AUTO;
  29. config.owner = THIS_MODULE;
  30. config.type = NVMEM_TYPE_OTP;
  31. config.root_only = true;
  32. @@ -912,7 +912,6 @@ static struct nvmem_device *mtd_otp_nvme
  33. nvmem = NULL;
  34. of_node_put(np);
  35. - kfree(config.name);
  36. return nvmem;
  37. }