spl: Pass spl_image as a parameter to load_image() methods

Rather than having a global variable, pass the spl_image as a parameter.
This avoids BSS use, and makes it clearer what the function is actually
doing.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index ed758e5..5cf712e 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -13,14 +13,15 @@
 #include <fdt.h>
 
 #if defined(CONFIG_SPL_NAND_RAW_ONLY)
-int spl_nand_load_image(struct spl_boot_device *bootdev)
+int spl_nand_load_image(struct spl_image_info *spl_image,
+			struct spl_boot_device *bootdev)
 {
 	nand_init();
 
 	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
 			    CONFIG_SYS_NAND_U_BOOT_SIZE,
 			    (void *)CONFIG_SYS_NAND_U_BOOT_DST);
-	spl_set_header_raw_uboot(&spl_image);
+	spl_set_header_raw_uboot(spl_image);
 	nand_deselect();
 
 	return 0;
@@ -39,7 +40,8 @@
 		return 0;
 }
 
-static int spl_nand_load_element(int offset, struct image_header *header)
+static int spl_nand_load_element(struct spl_image_info *spl_image,
+				 int offset, struct image_header *header)
 {
 	int err;
 
@@ -59,15 +61,16 @@
 		load.read = spl_nand_fit_read;
 		return spl_load_simple_fit(&load, offset, header);
 	} else {
-		err = spl_parse_image_header(&spl_image, header);
+		err = spl_parse_image_header(spl_image, header);
 		if (err)
 			return err;
-		return nand_spl_load_image(offset, spl_image.size,
-					   (void *)(ulong)spl_image.load_addr);
+		return nand_spl_load_image(offset, spl_image->size,
+					   (void *)(ulong)spl_image->load_addr);
 	}
 }
 
-static int spl_nand_load_image(struct spl_boot_device *bootdev)
+static int spl_nand_load_image(struct spl_image_info *spl_image,
+			       struct spl_boot_device *bootdev)
 {
 	int err;
 	struct image_header *header;
@@ -107,15 +110,15 @@
 		/* load linux */
 		nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
 			sizeof(*header), (void *)header);
-		err = spl_parse_image_header(&spl_image, header);
+		err = spl_parse_image_header(spl_image, header);
 		if (err)
 			return err;
 		if (header->ih_os == IH_OS_LINUX) {
 			/* happy - was a linux */
 			err = nand_spl_load_image(
 				CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
-				spl_image.size,
-				(void *)spl_image.load_addr);
+				spl_image->size,
+				(void *)spl_image->load_addr);
 			nand_deselect();
 			return err;
 		} else {
@@ -127,17 +130,19 @@
 	}
 #endif
 #ifdef CONFIG_NAND_ENV_DST
-	spl_nand_load_element(CONFIG_ENV_OFFSET, header);
+	spl_nand_load_element(spl_image, CONFIG_ENV_OFFSET, header);
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header);
+	spl_nand_load_element(spl_image, CONFIG_ENV_OFFSET_REDUND, header);
 #endif
 #endif
 	/* Load u-boot */
-	err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
+	err = spl_nand_load_element(spl_image, CONFIG_SYS_NAND_U_BOOT_OFFS,
+				    header);
 #ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
 #if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
 	if (err)
-		err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND,
+		err = spl_nand_load_element(spl_image,
+					    CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND,
 					    header);
 #endif
 #endif