[RFC PATCH 06/20] mtd: set flash_node on DT-created partitions

Daniel Golle daniel at makrotopia.org
Mon Feb 16 22:22:14 CET 2026


add_mtd_partitions_of() creates MTD partition slaves from device-tree
sub-nodes but never stores the originating ofnode on the partition.
This means there is no way to match a registered MTD partition back
to its DT node.

Set slave->flash_node = child right after allocate_partition() so
that every DT-created partition carries a reference to its DT node.
This will be used by the image_loader UBI backend to find the MTD
partition that corresponds to a 'compatible = "linux,ubi"' node.

Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 drivers/mtd/mtdpart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index f3b7f1ee13c..eac7215907b 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -940,6 +940,8 @@ int add_mtd_partitions_of(struct mtd_info *master)
 		if (IS_ERR(slave))
 			return PTR_ERR(slave);
 
+		slave->flash_node = child;
+
 		mutex_lock(&mtd_partitions_mutex);
 		list_add_tail(&slave->node, &master->partitions);
 		mutex_unlock(&mtd_partitions_mutex);
-- 
2.53.0


More information about the U-Boot mailing list