From dd5fe2ee73021e496adb39deaa1a451b3295f32c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Tue, 25 Aug 2015 10:32:43 +0200 Subject: [PATCH] fdt: fixup changes from commit 7a172ae7a3fc commit 7a172ae7a3fc "fdt: fix incorrect placement of partition information for atmel_nand" breaks the placement of the mtd partitions for other nand drivers. Correct the condition to break out of the loop searching for subnodes to fix this. --- common/fdt_support.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 891fcac08e..8fbe6b5132 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -711,9 +711,11 @@ static int fdt_del_subnodes(const void *blob, int parent_offset) for (ndepth = 0, off = fdt_next_node(blob, parent_offset, &ndepth); (off >= 0) && (ndepth > 0); off = fdt_next_node(blob, off, &ndepth)) { - if (ndepth != 1) + if (ndepth < 0) + break; + else if (ndepth != 1) continue; - if (fdt_getprop(blob, off, "compatible", NULL)) + else if (fdt_getprop(blob, off, "compatible", NULL)) continue; debug("delete %s: offset: %x\n", fdt_get_name(blob, off, 0), off); @@ -738,9 +740,11 @@ int fdt_del_partitions(void *blob, int parent_offset) int ret; while ((off = fdt_next_node(blob, off, &ndepth)) > 0) { - if (ndepth != 1) + if (ndepth < 0) + break; + else if (ndepth != 1) continue; - if (fdt_getprop(blob, off, "compatible", NULL)) + else if (fdt_getprop(blob, off, "compatible", NULL)) continue; prop = fdt_getprop(blob, off, "label", NULL); if (prop == NULL) { @@ -780,9 +784,11 @@ int fdt_node_set_part_info(void *blob, int parent_offset, * the offset in this case */ while ((off = fdt_next_node(blob, off, &ndepth)) > 0) { - if (ndepth != 1) + if (ndepth < 0) + break; + else if (ndepth != 1) continue; - if (fdt_getprop(blob, off, "compatible", NULL)) + else if (fdt_getprop(blob, off, "compatible", NULL)) continue; parent_offset = off; break; -- 2.39.2