1 From 658c4448bbbf02a143abf1b89d09a3337ebd3ba6 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Fri, 12 Mar 2021 07:28:19 +0100
4 Subject: [PATCH] mtd: core: add nvmem-cells compatible to parse mtd as nvmem
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Partitions that contains the nvmem-cells compatible will register
11 their direct subonodes as nvmem cells and the node will be treated as a
14 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
15 Tested-by: Rafał Miłecki <rafal@milecki.pl>
16 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
17 Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-1-ansuelsmth@gmail.com
19 drivers/mtd/mtdcore.c | 3 ++-
20 1 file changed, 2 insertions(+), 1 deletion(-)
22 --- a/drivers/mtd/mtdcore.c
23 +++ b/drivers/mtd/mtdcore.c
24 @@ -559,6 +559,7 @@ static int mtd_nvmem_reg_read(void *priv
26 static int mtd_nvmem_add(struct mtd_info *mtd)
28 + struct device_node *node = mtd_get_of_node(mtd);
29 struct nvmem_config config = {};
32 @@ -571,7 +572,7 @@ static int mtd_nvmem_add(struct mtd_info
34 config.read_only = true;
35 config.root_only = true;
36 - config.no_of_node = true;
37 + config.no_of_node = !of_device_is_compatible(node, "nvmem-cells");
40 mtd->nvmem = nvmem_register(&config);