28335cb71f080d49f83c531ce9737bc7318d382c
[openwrt/staging/aparcar.git] /
1 From a5d83d6e2bc747b13f347962d4b335d70b23559b 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
5 cells
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
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
12 nvmem provider.
13
14 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
15 Tested-by: Rafał Miłecki <rafal@milecki.pl>
16 ---
17 drivers/mtd/mtdcore.c | 3 ++-
18 1 file changed, 2 insertions(+), 1 deletion(-)
19
20 --- a/drivers/mtd/mtdcore.c
21 +++ b/drivers/mtd/mtdcore.c
22 @@ -531,6 +531,7 @@ static int mtd_nvmem_reg_read(void *priv
23
24 static int mtd_nvmem_add(struct mtd_info *mtd)
25 {
26 + struct device_node *node = mtd_get_of_node(mtd);
27 struct nvmem_config config = {};
28
29 config.id = -1;
30 @@ -543,7 +544,7 @@ static int mtd_nvmem_add(struct mtd_info
31 config.stride = 1;
32 config.read_only = true;
33 config.root_only = true;
34 - config.no_of_node = true;
35 + config.no_of_node = !of_device_is_compatible(node, "nvmem-cells");
36 config.priv = mtd;
37
38 mtd->nvmem = nvmem_register(&config);