[new uImage] rework error handling so common functions don't reset

Changed image_get_ramdisk() to just return NULL on error and have
get_ramdisk() propogate that error to the caller.  It's left to the
caller to call do_reset() if it wants to.

Also moved calling do_reset() in get_fdt() and fdt_relocate() on ppc
to a common location.  In the future we will change get_fdt() and
fdt_relocate() to return success/failure and not call do_reset() at all.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Marian Balakowicz <m8@semihalf.com>
diff --git a/common/image.c b/common/image.c
index 92c067f..d4acb6b 100644
--- a/common/image.c
+++ b/common/image.c
@@ -51,8 +51,6 @@
 #include <fdt_support.h>
 #endif
 
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
 #ifdef CONFIG_CMD_BDI
 extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 #endif
@@ -491,7 +489,7 @@
  *
  * returns:
  *     pointer to a ramdisk image header, if image was found and valid
- *     otherwise, board is reset
+ *     otherwise, return NULL
  */
 static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 		int argc, char *argv[],
@@ -505,13 +503,13 @@
 	if (!image_check_magic (rd_hdr)) {
 		puts ("Bad Magic Number\n");
 		show_boot_progress (-10);
-		do_reset (cmdtp, flag, argc, argv);
+		return NULL;
 	}
 
 	if (!image_check_hcrc (rd_hdr)) {
 		puts ("Bad Header Checksum\n");
 		show_boot_progress (-11);
-		do_reset (cmdtp, flag, argc, argv);
+		return NULL;
 	}
 
 	show_boot_progress (10);
@@ -522,7 +520,7 @@
 		if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) {
 			puts ("Bad Data CRC\n");
 			show_boot_progress (-12);
-			do_reset (cmdtp, flag, argc, argv);
+			return NULL;
 		}
 		puts("OK\n");
 	}
@@ -535,7 +533,7 @@
 		printf ("No Linux %s Ramdisk Image\n",
 				image_get_arch_name(arch));
 		show_boot_progress (-13);
-		do_reset (cmdtp, flag, argc, argv);
+		return NULL;
 	}
 
 	return rd_hdr;
@@ -561,9 +559,9 @@
  *     rd_start and rd_end are set to ramdisk start/end addresses if
  *     ramdisk image is found and valid
  *     rd_start and rd_end are set to 0 if no ramdisk exists
- *     board is reset if ramdisk image is found but corrupted
+ *     return 1 if ramdisk image is found but corrupted
  */
-void get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		bootm_headers_t *images, uint8_t arch,
 		ulong *rd_start, ulong *rd_end)
 {
@@ -630,6 +628,12 @@
 			rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
 						rd_addr, arch, images->verify);
 
+			if (rd_hdr == NULL) {
+				*rd_start = 0;
+				*rd_end = 0;
+				return 1;
+			}
+
 			rd_data = image_get_data (rd_hdr);
 			rd_len = image_get_data_size (rd_hdr);
 			rd_load = image_get_load (rd_hdr);
@@ -639,7 +643,7 @@
 			fit_hdr = (void *)rd_addr;
 			debug ("*  ramdisk: FIT format image\n");
 			fit_unsupported_reset ("ramdisk");
-			do_reset (cmdtp, flag, argc, argv);
+			return 1;
 #endif
 		default:
 			printf ("Wrong Image Format for %s command\n",
@@ -687,6 +691,8 @@
 	}
 	debug ("   ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
 			*rd_start, *rd_end);
+
+	return 0;
 }
 
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)