1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Date: Tue, 31 Oct 2023 15:51:01 +0100
3 Subject: [PATCH] mtd: don't register NVMEM devices for partitions with custom
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 This fixes issue exposed by upstream commit f4cf4e5db331 ("Revert
10 "nvmem: add new config option"").
12 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
14 drivers/mtd/mtdcore.c | 23 +++++++++++++++++++++++
15 1 file changed, 23 insertions(+)
17 --- a/drivers/mtd/mtdcore.c
18 +++ b/drivers/mtd/mtdcore.c
19 @@ -548,6 +548,29 @@ static int mtd_nvmem_add(struct mtd_info
20 struct device_node *node = mtd_get_of_node(mtd);
21 struct nvmem_config config = {};
24 + * Do NOT register NVMEM device for any partition that is meant to be
25 + * handled by a U-Boot env driver. That would result in associating two
26 + * different NVMEM devices with the same OF node.
28 + * An example of unwanted behaviour of above (forwardtrace):
29 + * of_get_mac_addr_nvmem()
30 + * of_nvmem_cell_get()
31 + * __nvmem_device_get()
33 + * We can't have __nvmem_device_get() return "mtdX" NVMEM device instead
34 + * of U-Boot env NVMEM device. That would result in failing to find
37 + * This issue seems to affect U-Boot env case only and will go away with
38 + * switch to NVMEM layouts.
40 + if (of_device_is_compatible(node, "u-boot,env") ||
41 + of_device_is_compatible(node, "u-boot,env-redundant-bool") ||
42 + of_device_is_compatible(node, "u-boot,env-redundant-count") ||
43 + of_device_is_compatible(node, "brcm,env"))
46 config.id = NVMEM_DEVID_NONE;
47 config.dev = &mtd->dev;
48 config.name = dev_name(&mtd->dev);