diff mbox series

[2/2] mtd: core: find OF node for every MTD partition

Message ID 20220707163607.20729-2-zajec5@gmail.com
State New
Headers show
Series [1/2] mtd: core: simplify (a bit) code find partition-matching dynamic OF node | expand

Commit Message

Rafał Miłecki July 7, 2022, 4:36 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

Don't limit this feature to the "nvmem-cells". There are more cases to
this.
1. Dynamic partitions may need to be handled with parsers
   This applies to "fixed-partitions" parser and all custom ones.
2. Dynamic partitions can be handled with specific drivers
   Consider "u-boot,env" as specified in the u-boot,env.yaml.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/mtd/mtdcore.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Comments

Rafał Miłecki July 11, 2022, 9:45 a.m. UTC | #1
On 7.07.2022 18:36, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Don't limit this feature to the "nvmem-cells". There are more cases to
> this.
> 1. Dynamic partitions may need to be handled with parsers
>     This applies to "fixed-partitions" parser and all custom ones.
> 2. Dynamic partitions can be handled with specific drivers
>     Consider "u-boot,env" as specified in the u-boot,env.yaml.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

This code needs more work, please drop this patchset for now.
diff mbox series

Patch

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 79c447fe30b4..f7693736dde4 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -552,7 +552,6 @@  static void mtd_check_of_node(struct mtd_info *mtd)
 	const char *pname, *prefix = "partition-";
 	int plen, mtd_name_len, offset, prefix_len;
 	struct mtd_info *parent;
-	bool found = false;
 
 	/* Check if MTD already has a device node */
 	if (dev_of_node(&mtd->dev))
@@ -588,19 +587,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);