diff mbox series

common: fdt_support: add support for "partitions" subnode to fdt_fixup_mtdparts()

Message ID 20220203141447.986798-1-matthias.schiffer@ew.tq-group.com
State Accepted
Commit 36fee2f7621eb2074be17bb0c4f8c950b0362c52
Delegated to: Tom Rini
Headers show
Series common: fdt_support: add support for "partitions" subnode to fdt_fixup_mtdparts() | expand

Commit Message

Matthias Schiffer Feb. 3, 2022, 2:14 p.m. UTC
Listing MTD partitions directly in the flash mode has been deprecated
for a while for kernel Device Trees. Look for a node "partitions" in the
found flash nodes and use it instead of the flash node itself for the
partition list when it exists, so Device Trees following the current
best practices can be fixed up.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 common/fdt_support.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Simon Glass Feb. 4, 2022, 3:24 p.m. UTC | #1
On Thu, 3 Feb 2022 at 07:15, Matthias Schiffer
<matthias.schiffer@ew.tq-group.com> wrote:
>
> Listing MTD partitions directly in the flash mode has been deprecated
> for a while for kernel Device Trees. Look for a node "partitions" in the
> found flash nodes and use it instead of the flash node itself for the
> partition list when it exists, so Device Trees following the current
> best practices can be fixed up.
>
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> ---
>  common/fdt_support.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Feb. 11, 2022, 5:07 p.m. UTC | #2
On Thu, Feb 03, 2022 at 03:14:47PM +0100, Matthias Schiffer wrote:

> Listing MTD partitions directly in the flash mode has been deprecated
> for a while for kernel Device Trees. Look for a node "partitions" in the
> found flash nodes and use it instead of the flash node itself for the
> partition list when it exists, so Device Trees following the current
> best practices can be fixed up.
> 
> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/fdt_support.c b/common/fdt_support.c
index daa24d4c10..ea18ea3f04 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -988,7 +988,7 @@  void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
 {
 	struct mtd_device *dev;
 	int i, idx;
-	int noff;
+	int noff, parts;
 	bool inited = false;
 
 	for (i = 0; i < node_info_size; i++) {
@@ -1014,7 +1014,12 @@  void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info,
 
 			dev = device_find(node_info[i].type, idx++);
 			if (dev) {
-				if (fdt_node_set_part_info(blob, noff, dev))
+				parts = fdt_subnode_offset(blob, noff,
+							   "partitions");
+				if (parts < 0)
+					parts = noff;
+
+				if (fdt_node_set_part_info(blob, parts, dev))
 					return; /* return on error */
 			}
 		}