lkml.org 
[lkml]   [2020]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 1/4] mtd: Add nvmem support for mtd nvmem-providers
Date
Introduce 2 new bindings for the mtd structure.
Mtd partitions can be set as 'nvmem-provider' and any subpartition defined
with the tag 'nvmem-cell' are skipped by the 'fixed-partitions' parser
and registred as a nvmem cell by the nvmem api.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
drivers/mtd/mtdcore.c | 3 ++-
drivers/mtd/parsers/ofpart.c | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 7d930569a7df..ba5236db8318 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -551,6 +551,7 @@ static int mtd_nvmem_reg_read(void *priv, unsigned int offset,

static int mtd_nvmem_add(struct mtd_info *mtd)
{
+ struct device_node *mtd_node = mtd_get_of_node(mtd);
struct nvmem_config config = {};

config.id = -1;
@@ -563,7 +564,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
config.stride = 1;
config.read_only = true;
config.root_only = true;
- config.no_of_node = true;
+ config.no_of_node = !of_property_read_bool(mtd_node, "nvmem-provider");
config.priv = mtd;

mtd->nvmem = nvmem_register(&config);
diff --git a/drivers/mtd/parsers/ofpart.c b/drivers/mtd/parsers/ofpart.c
index daf507c123e6..442e039214bc 100644
--- a/drivers/mtd/parsers/ofpart.c
+++ b/drivers/mtd/parsers/ofpart.c
@@ -61,6 +61,10 @@ static int parse_fixed_partitions(struct mtd_info *master,
if (!dedicated && node_has_compatible(pp))
continue;

+ /* skip adding if a nvmem-cell is detected */
+ if (of_property_read_bool(pp, "nvmem-cell"))
+ continue;
+
nr_parts++;
}

@@ -80,6 +84,10 @@ static int parse_fixed_partitions(struct mtd_info *master,
if (!dedicated && node_has_compatible(pp))
continue;

+ /* skip adding if a nvmem-cell is detected */
+ if (of_property_read_bool(pp, "nvmem-cell"))
+ continue;
+
reg = of_get_property(pp, "reg", &len);
if (!reg) {
if (dedicated) {
--
2.27.0
\
 
 \ /
  Last update: 2020-09-20 11:58    [W:0.051 / U:1.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site