summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2022-10-04 10:37:10 +0200
committerMiquel Raynal <miquel.raynal@bootlin.com>2022-11-07 17:07:56 +0100
commit2df11f00100d7278185a9dbefa20ba3f5d32401d (patch)
tree200a65259a2a1854f9febd79e10191b84dcedbd0 /drivers/mtd
parentc5f5d0cd40e3bc2d6d397af788a7c0241b1c6b68 (diff)
mtd: core: try to find OF node for every MTD partition
So far this feature was limited to the top-level "nvmem-cells" node. There are multiple parsers creating partitions and subpartitions dynamically. Extend that code to handle them too. This allows finding partition-* node for every MTD (sub)partition. Random example: partitions { compatible = "brcm,bcm947xx-cfe-partitions"; partition-firmware { compatible = "brcm,trx"; partition-loader { }; }; }; Cc: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20221004083710.27704-2-zajec5@gmail.com
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtdcore.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 6ad62ff7be23..20fcedc3021e 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -551,13 +551,11 @@ static void mtd_check_of_node(struct mtd_info *mtd)
struct device_node *partitions, *parent_dn, *mtd_dn = NULL;
const char *pname, *prefix = "partition-";
int plen, mtd_name_len, offset, prefix_len;
- bool found = false;
/* Check if MTD already has a device node */
if (mtd_get_of_node(mtd))
return;
- /* Check if a partitions node exist */
if (!mtd_is_partition(mtd))
return;
@@ -565,7 +563,10 @@ static void mtd_check_of_node(struct mtd_info *mtd)
if (!parent_dn)
return;
- partitions = of_get_child_by_name(parent_dn, "partitions");
+ if (mtd_is_partition(mtd->parent))
+ partitions = of_node_get(parent_dn);
+ else
+ partitions = of_get_child_by_name(parent_dn, "partitions");
if (!partitions)
goto exit_parent;
@@ -589,19 +590,11 @@ static void mtd_check_of_node(struct mtd_info *mtd)
plen = strlen(pname) - offset;
if (plen == mtd_name_len &&
!strncmp(mtd->name, pname + offset, plen)) {
- found = true;
+ mtd_set_of_node(mtd, mtd_dn);
break;
}
}
- if (!found)
- goto exit_partitions;
-
- /* Set of_node only for nvmem */
- if (of_device_is_compatible(mtd_dn, "nvmem-cells"))
- mtd_set_of_node(mtd, mtd_dn);
-
-exit_partitions:
of_node_put(partitions);
exit_parent:
of_node_put(parent_dn);