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/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index 22f3e3c..7713813 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -134,7 +134,8 @@
 }
 
 #ifdef CONFIG_SPL_BUILD
-static int spl_board_load_image(struct spl_boot_device *bootdev)
+static int spl_board_load_image(struct spl_image_info *spl_image,
+				struct spl_boot_device *bootdev)
 {
 	debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
 	return_to_fel(fel_stash.sp, fel_stash.lr);
diff --git a/arch/arm/mach-uniphier/boot-mode/spl_board.c b/arch/arm/mach-uniphier/boot-mode/spl_board.c
index e2b202e..854ab05 100644
--- a/arch/arm/mach-uniphier/boot-mode/spl_board.c
+++ b/arch/arm/mach-uniphier/boot-mode/spl_board.c
@@ -65,7 +65,8 @@
 	return 0;
 }
 
-static int spl_board_load_image(struct spl_boot_device *bootdev)
+static int spl_board_load_image(struct spl_image_info *spl_image,
+				struct spl_boot_device *bootdev)
 {
 	int (*send_cmd)(u32 cmd, u32 arg);
 	int (*card_blockaddr)(u32 rca);
@@ -113,12 +114,12 @@
 		return ret;
 	}
 
-	ret = spl_parse_image_header(&spl_image, (void *)CONFIG_SYS_TEXT_BASE);
+	ret = spl_parse_image_header(spl_image, (void *)CONFIG_SYS_TEXT_BASE);
 	if (ret)
 		return ret;
 
-	ret = (*load_image)(dev_addr, spl_image.load_addr,
-			    spl_image.size / 512);
+	ret = (*load_image)(dev_addr, spl_image->load_addr,
+			    spl_image->size / 512);
 	if (ret) {
 		printf("failed to load image\n");
 		return ret;
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 2c45354..1ad7fb6 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -38,7 +38,8 @@
 	printf("%s\n", fname);
 }
 
-static int spl_board_load_image(struct spl_boot_device *bootdev)
+static int spl_board_load_image(struct spl_image_info *spl_image,
+				struct spl_boot_device *bootdev)
 {
 	char fname[256];
 	int ret;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 84c8034..fae3dbc 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -185,7 +185,8 @@
 	return count;
 }
 
-static int spl_ram_load_image(struct spl_boot_device *bootdev)
+static int spl_ram_load_image(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
 {
 	struct image_header *header;
 
@@ -215,7 +216,7 @@
 		header = (struct image_header *)
 			(CONFIG_SYS_TEXT_BASE -	sizeof(struct image_header));
 
-		spl_parse_image_header(&spl_image, header);
+		spl_parse_image_header(spl_image, header);
 	}
 
 	return 0;
@@ -381,7 +382,7 @@
 	bootdev.boot_device = boot_device;
 	bootdev.boot_device_name = NULL;
 	if (loader)
-		return loader->load_image(&bootdev);
+		return loader->load_image(&spl_image, &bootdev);
 
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 	puts("SPL: Unsupported Boot Device!\n");
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 5e8172e..6536e66 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -18,26 +18,26 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int mmc_load_legacy(struct mmc *mmc, ulong sector,
-			   struct image_header *header)
+static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
+			   ulong sector, struct image_header *header)
 {
 	u32 image_size_sectors;
 	unsigned long count;
 	int ret;
 
-	ret = spl_parse_image_header(&spl_image, header);
+	ret = spl_parse_image_header(spl_image, header);
 	if (ret)
 		return ret;
 
 	/* convert size to sectors - round up */
-	image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) /
+	image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) /
 			     mmc->read_bl_len;
 
 	/* Read the header too to avoid extra memcpy */
 	count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors,
-			  (void *)(ulong)spl_image.load_addr);
+			  (void *)(ulong)spl_image->load_addr);
 	debug("read %x sectors to %x\n", image_size_sectors,
-	      spl_image.load_addr);
+	      spl_image->load_addr);
 	if (count != image_size_sectors)
 		return -EIO;
 
@@ -52,7 +52,8 @@
 	return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
 }
 
-static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
+static int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
+				     struct mmc *mmc, unsigned long sector)
 {
 	unsigned long count;
 	struct image_header *header;
@@ -81,7 +82,7 @@
 		load.read = h_spl_load_read;
 		ret = spl_load_simple_fit(&load, sector, header);
 	} else {
-		ret = mmc_load_legacy(mmc, sector, header);
+		ret = mmc_load_legacy(spl_image, mmc, sector, header);
 	}
 
 end:
@@ -150,7 +151,8 @@
 }
 
 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
-static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
+static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
+					struct mmc *mmc, int partition)
 {
 	disk_partition_t info;
 	int err;
@@ -164,22 +166,24 @@
 	}
 
 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
-	return mmc_load_image_raw_sector(mmc, info.start +
-					 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
+	return mmc_load_image_raw_sector(spl_image, mmc,
+			info.start + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
 #else
-	return mmc_load_image_raw_sector(mmc, info.start);
+	return mmc_load_image_raw_sector(spl_image, mmc, info.start);
 #endif
 }
 #else
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION -1
-static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
+static int mmc_load_image_raw_partition(struct spl_image_info *spl_image,
+					struct mmc *mmc, int partition)
 {
 	return -ENOSYS;
 }
 #endif
 
 #ifdef CONFIG_SPL_OS_BOOT
-static int mmc_load_image_raw_os(struct mmc *mmc)
+static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
+				 struct mmc *mmc)
 {
 	unsigned long count;
 	int ret;
@@ -195,12 +199,12 @@
 		return -1;
 	}
 
-	ret = mmc_load_image_raw_sector(mmc,
+	ret = mmc_load_image_raw_sector(spl_image, mmc,
 		CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
 	if (ret)
 		return ret;
 
-	if (spl_image.os != IH_OS_LINUX) {
+	if (spl_image->os != IH_OS_LINUX) {
 		puts("Expected Linux image is not found. Trying to start U-boot\n");
 		return -ENOENT;
 	}
@@ -212,14 +216,15 @@
 {
 	return 1;
 }
-static int mmc_load_image_raw_os(struct mmc *mmc)
+static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
+				 struct mmc *mmc)
 {
 	return -ENOSYS;
 }
 #endif
 
 #ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
-int spl_mmc_do_fs_boot(struct mmc *mmc)
+static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
 {
 	int err = -ENOSYS;
 
@@ -261,13 +266,14 @@
 	return err;
 }
 #else
-int spl_mmc_do_fs_boot(struct mmc *mmc)
+static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
 {
 	return -ENOSYS;
 }
 #endif
 
-static int spl_mmc_load_image(struct spl_boot_device *bootdev)
+static int spl_mmc_load_image(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
 {
 	struct mmc *mmc = NULL;
 	u32 boot_mode;
@@ -312,17 +318,17 @@
 		debug("spl: mmc boot mode: raw\n");
 
 		if (!spl_start_uboot()) {
-			err = mmc_load_image_raw_os(mmc);
+			err = mmc_load_image_raw_os(spl_image, mmc);
 			if (!err)
 				return err;
 		}
 
-		err = mmc_load_image_raw_partition(mmc,
+		err = mmc_load_image_raw_partition(spl_image, mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
 		if (!err)
 			return err;
 #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
-		err = mmc_load_image_raw_sector(mmc,
+		err = mmc_load_image_raw_sector(spl_image, mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
 		if (!err)
 			return err;
@@ -331,7 +337,7 @@
 	case MMCSD_MODE_FS:
 		debug("spl: mmc boot mode: fs\n");
 
-		err = spl_mmc_do_fs_boot(mmc);
+		err = spl_mmc_do_fs_boot(spl_image, mmc);
 		if (!err)
 			return err;
 
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
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index 0cbd995..f4b4bc4 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -15,7 +15,8 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)
-static int spl_net_load_image(struct spl_boot_device *bootdev)
+static int spl_net_load_image(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
 {
 	int rv;
 
@@ -35,29 +36,31 @@
 		printf("Problem booting with BOOTP\n");
 		return rv;
 	}
-	return spl_parse_image_header(&spl_image,
+	return spl_parse_image_header(spl_image,
 				      (struct image_header *)load_addr);
 }
 #endif
 
 #ifdef CONFIG_SPL_ETH_SUPPORT
-int spl_net_load_image_cpgmac(struct spl_boot_device *bootdev)
+int spl_net_load_image_cpgmac(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
 {
 #ifdef CONFIG_SPL_ETH_DEVICE
 	bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE;
 #endif
 
-	return spl_net_load_image(bootdev);
+	return spl_net_load_image(spl_image, bootdev);
 }
 SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_CPGMAC, spl_net_load_image_cpgmac);
 #endif
 
 #ifdef CONFIG_SPL_USBETH_SUPPORT
-int spl_net_load_image_usb(struct spl_boot_device *bootdev)
+int spl_net_load_image_usb(struct spl_image_info *spl_image,
+			   struct spl_boot_device *bootdev)
 {
 	bootdev->boot_device_name = "usb_ether";
 
-	return spl_net_load_image(bootdev);
+	return spl_net_load_image(spl_image, bootdev);
 }
 SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);
 #endif
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index b55fcc5..6bfa399 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -7,14 +7,15 @@
 #include <common.h>
 #include <spl.h>
 
-static int spl_nor_load_image(struct spl_boot_device *bootdev)
+static int spl_nor_load_image(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
 {
 	int ret;
 	/*
 	 * Loading of the payload to SDRAM is done with skipping of
 	 * the mkimage header in this SPL NOR driver
 	 */
-	spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
+	spl_image->flags |= SPL_COPY_PAYLOAD_ONLY;
 
 #ifdef CONFIG_SPL_OS_BOOT
 	if (!spl_start_uboot()) {
@@ -29,14 +30,14 @@
 		if (image_get_os(header) == IH_OS_LINUX) {
 			/* happy - was a Linux */
 
-			ret = spl_parse_image_header(&spl_image, header);
+			ret = spl_parse_image_header(spl_image, header);
 			if (ret)
 				return ret;
 
-			memcpy((void *)spl_image.load_addr,
+			memcpy((void *)spl_image->load_addr,
 			       (void *)(CONFIG_SYS_OS_BASE +
 					sizeof(struct image_header)),
-			       spl_image.size);
+			       spl_image->size);
 
 			/*
 			 * Copy DT blob (fdt) to SDRAM. Passing pointer to
@@ -59,14 +60,14 @@
 	 * Load real U-Boot from its location in NOR flash to its
 	 * defined location in SDRAM
 	 */
-	ret = spl_parse_image_header(&spl_image,
+	ret = spl_parse_image_header(spl_image,
 			(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
 	if (ret)
 		return ret;
 
-	memcpy((void *)(unsigned long)spl_image.load_addr,
+	memcpy((void *)(unsigned long)spl_image->load_addr,
 	       (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
-	       spl_image.size);
+	       spl_image->size);
 
 	return 0;
 }
diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c
index 361a1b3..f076e2c 100644
--- a/common/spl/spl_onenand.c
+++ b/common/spl/spl_onenand.c
@@ -14,7 +14,8 @@
 #include <asm/io.h>
 #include <onenand_uboot.h>
 
-static int spl_onenand_load_image(struct spl_boot_device *bootdev)
+static int spl_onenand_load_image(struct spl_image_info *spl_image,
+				  struct spl_boot_device *bootdev)
 {
 	struct image_header *header;
 	int ret;
@@ -26,11 +27,11 @@
 	/* Load u-boot */
 	onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
 		CONFIG_SYS_ONENAND_PAGE_SIZE, (void *)header);
-	ret = spl_parse_image_header(&spl_image, header);
+	ret = spl_parse_image_header(spl_image, header);
 	if (ret)
 		return ret;
 	onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
-		spl_image.size, (void *)spl_image.load_addr);
+		spl_image->size, (void *)spl_image->load_addr);
 
 	return 0;
 }
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index 1a21c05..19b5ba5 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -20,7 +20,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int spl_sata_load_image(struct spl_boot_device *bootdev)
+static int spl_sata_load_image(struct spl_image_info *spl_image,
+			       struct spl_boot_device *bootdev)
 {
 	int err;
 	struct blk_desc *stor_dev;
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index b9294f2..4bf3d65 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -20,7 +20,8 @@
  * Load the kernel, check for a valid header we can parse, and if found load
  * the kernel and then device tree.
  */
-static int spi_load_image_os(struct spi_flash *flash,
+static int spi_load_image_os(struct spl_image_info *spl_image,
+			     struct spi_flash *flash,
 			     struct image_header *header)
 {
 	int err;
@@ -32,12 +33,12 @@
 	if (image_get_magic(header) != IH_MAGIC)
 		return -1;
 
-	err = spl_parse_image_header(&spl_image, header);
+	err = spl_parse_image_header(spl_image, header);
 	if (err)
 		return err;
 
 	spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS,
-		       spl_image.size, (void *)spl_image.load_addr);
+		       spl_image->size, (void *)spl_image->load_addr);
 
 	/* Read device tree. */
 	spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
@@ -65,7 +66,8 @@
  * configured and available since this code loads the main U-Boot image
  * from SPI into SDRAM and starts it from there.
  */
-static int spl_spi_load_image(struct spl_boot_device *bootdev)
+static int spl_spi_load_image(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
 {
 	int err = 0;
 	struct spi_flash *flash;
@@ -88,7 +90,7 @@
 	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
 
 #ifdef CONFIG_SPL_OS_BOOT
-	if (spl_start_uboot() || spi_load_image_os(flash, header))
+	if (spl_start_uboot() || spi_load_image_os(spl_image, flash, header))
 #endif
 	{
 		/* Load u-boot, mkimage header is 64 bytes. */
@@ -110,12 +112,12 @@
 						  CONFIG_SYS_SPI_U_BOOT_OFFS,
 						  header);
 		} else {
-			err = spl_parse_image_header(&spl_image, header);
+			err = spl_parse_image_header(spl_image, header);
 			if (err)
 				return err;
 			err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
-					     spl_image.size,
-					     (void *)spl_image.load_addr);
+					     spl_image->size,
+					     (void *)spl_image->load_addr);
 		}
 	}
 
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index 3ef00aa..c03910b 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -12,7 +12,8 @@
 #include <ubispl.h>
 #include <spl.h>
 
-int spl_ubi_load_image(struct spl_boot_device *bootdev)
+int spl_ubi_load_image(struct spl_image_info *spl_image,
+		       struct spl_boot_device *bootdev)
 {
 	struct image_header *header;
 	struct ubispl_info info;
@@ -54,7 +55,7 @@
 		ret = ubispl_load_volumes(&info, volumes, 2);
 		if (!ret) {
 			header = (struct image_header *)volumes[0].load_addr;
-			spl_parse_image_header(&spl_image, header);
+			spl_parse_image_header(spl_image, header);
 			puts("Linux loaded.\n");
 			goto out;
 		}
@@ -68,7 +69,7 @@
 
 	ret = ubispl_load_volumes(&info, volumes, 1);
 	if (!ret)
-		spl_parse_image_header(&spl_image, header);
+		spl_parse_image_header(spl_image, header);
 out:
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	if (bootdev->boot_device == BOOT_DEVICE_NAND)
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c
index 2bc321a..aaa4f81 100644
--- a/common/spl/spl_usb.c
+++ b/common/spl/spl_usb.c
@@ -22,7 +22,8 @@
 static int usb_stor_curr_dev = -1; /* current device */
 #endif
 
-static int spl_usb_load_image(struct spl_boot_device *bootdev)
+static int spl_usb_load_image(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
 {
 	int err;
 	struct blk_desc *stor_dev;
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 168b951..8fbf895 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -68,7 +68,8 @@
 	return size;
 }
 
-static int spl_ymodem_load_image(struct spl_boot_device *bootdev)
+static int spl_ymodem_load_image(struct spl_image_info *spl_image,
+				 struct spl_boot_device *bootdev)
 {
 	int size = 0;
 	int err;
@@ -108,12 +109,12 @@
 		while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0)
 			size += res;
 	} else {
-		spl_parse_image_header(&spl_image, (struct image_header *)buf);
-		ret = spl_parse_image_header(&spl_image,
+		spl_parse_image_header(spl_image, (struct image_header *)buf);
+		ret = spl_parse_image_header(spl_image,
 					     (struct image_header *)buf);
 		if (ret)
 			return ret;
-		addr = spl_image.load_addr;
+		addr = spl_image->load_addr;
 		memcpy((void *)addr, buf, res);
 		size += res;
 		addr += res;
diff --git a/include/spl.h b/include/spl.h
index 895240d..dd1d609 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -160,9 +160,11 @@
 	/**
 	 * load_image() - Load an SPL image
 	 *
+	 * @spl_image: place to put image information
 	 * @bootdev: describes the boot device to load from
 	 */
-	int (*load_image)(struct spl_boot_device *bootdev);
+	int (*load_image)(struct spl_image_info *spl_image,
+			  struct spl_boot_device *bootdev);
 };
 
 /* Declare an SPL image loader */