@@ -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);
@@ -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) {
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(-)