[U-Boot] [PATCH 07/11] fdt: Tidy up error handling in image_setup_libfdt()

Simon Glass sjg at chromium.org
Wed Oct 15 10:05:37 CEST 2014


The message about needing to reset should be printed no matter what error
is printed. Also, an error should always be printed.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 common/image-fdt.c    | 27 +++++++++++++++++----------
 include/fdt_support.h |  1 +
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/common/image-fdt.c b/common/image-fdt.c
index a2342fa..8fbb0d0 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -460,19 +460,22 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
 {
 	ulong *initrd_start = &images->initrd_start;
 	ulong *initrd_end = &images->initrd_end;
-	int ret;
+	int ret = -EPERM;
 
 	if (fdt_chosen(blob) < 0) {
-		puts("ERROR: /chosen node create failed");
-		puts(" - must RESET the board to recover.\n");
-		return -1;
+		printf("ERROR: /chosen node create failed\n");
+		goto err;
 	}
 	if (arch_fixup_fdt(blob) < 0) {
-		puts("ERROR: arch specific fdt fixup failed");
-		return -1;
+		printf("ERROR: arch-specific fdt fixup failed\n");
+		goto err;
+	}
+	if (IMAGE_OF_BOARD_SETUP) {
+		if (ft_board_setup(blob, gd->bd)) {
+			printf("ERROR: board-specific fdt fixup failed\n");
+			goto err;
+		}
 	}
-	if (IMAGE_OF_BOARD_SETUP)
-		ft_board_setup(blob, gd->bd);
 	fdt_fixup_ethernet(blob);
 
 	/* Delete the old LMB reservation */
@@ -481,7 +484,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
 
 	ret = fdt_shrink_to_minimum(blob);
 	if (ret < 0)
-		return ret;
+		goto err;
 	of_size = ret;
 
 	if (*initrd_start && *initrd_end) {
@@ -493,7 +496,7 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
 
 	fdt_initrd(blob, *initrd_start, *initrd_end);
 	if (!ft_verify_fdt(blob))
-		return -1;
+		goto err;
 
 #if defined(CONFIG_SOC_KEYSTONE)
 	if (IMAGE_OF_BOARD_SETUP)
@@ -501,4 +504,8 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
 #endif
 
 	return 0;
+err:
+	printf(" - must RESET the board to recover.\n\n");
+
+	return ret;
 }
diff --git a/include/fdt_support.h b/include/fdt_support.h
index c0278d6..f65ebfa 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -80,6 +80,7 @@ int fdt_find_or_add_subnode(void *fdt, int parentoffset, const char *name);
  * Add board-specific data to the FDT before booting the OS.
  *
  * Use CONFIG_SYS_FDT_PAD to ensure there is sufficient space.
+ * This function is called if CONFIG_OF_BOARD_SETUP is defined
  *
  * @param blob		FDT blob to update
  * @param bd_t		Pointer to board data
-- 
2.1.0.rc2.206.gedb03e5



More information about the U-Boot mailing list