kernel: Move an upstreamed patch under backports
[openwrt/openwrt.git] / target / linux / generic / backport-5.4 / 406-v5.13-0001-mtd-core-add-nvmem-cells-compatible-to-parse-mtd-as-.patch
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
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 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
17 Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-1-ansuelsmth@gmail.com
18 ---
19 drivers/mtd/mtdcore.c | 3 ++-
20 1 file changed, 2 insertions(+), 1 deletion(-)
21
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
25
26 static int mtd_nvmem_add(struct mtd_info *mtd)
27 {
28 + struct device_node *node = mtd_get_of_node(mtd);
29 struct nvmem_config config = {};
30
31 config.id = -1;
32 @@ -571,7 +572,7 @@ static int mtd_nvmem_add(struct mtd_info
33 config.stride = 1;
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");
38 config.priv = mtd;
39
40 mtd->nvmem = nvmem_register(&config);