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
---
arch/arm/mach-sunxi/board.c | 3 +-
arch/arm/mach-uniphier/boot-mode/spl_board.c | 9 ++---
arch/sandbox/cpu/spl.c | 3 +-
common/spl/spl.c | 7 ++--
common/spl/spl_mmc.c | 54 +++-
common/spl/spl_nand.c| 33 +
common/spl/spl_net.c | 15
common/spl/spl_nor.c | 17 -
common/spl/spl_onenand.c | 7 ++--
common/spl/spl_sata.c| 3 +-
common/spl/spl_spi.c | 18 +-
common/spl/spl_ubi.c | 7 ++--
common/spl/spl_usb.c | 3 +-
common/spl/spl_ymodem.c | 9 ++---
include/spl.h| 4 ++-
15 files changed, 110 insertions(+), 82 deletions(-)
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 @@ static int gpio_init(void)
}
#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 @@ int uniphier_rom_get_mmc_funcptr(int (**send_cmd)(u32, u32),
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 @@ static int spl_board_load_image(struct spl_boot_device
*bootdev)
return ret;
}
- ret = spl_parse_image_header(_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 @@ void spl_board_announce_boot_device(void)
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 e0d0c9e..e295b2e 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -185,7 +185,8 @@ static ulong spl_ram_load_read(struct spl_load_info *load,
ulong sector,
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;
@@ -210,7 +211,7 @@ static int spl_ram_load_image(struct spl_boot_device
*bootdev)
header = (struct image_header *)
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
- spl_parse_image_header(_image, header);
+ spl_parse_image_header(spl_image, header);
}
return 0;
@@ -370,7 +371,7 @@ static int spl_load_image(u32 boot_device)
bootdev.boot_device = boot_device;
bootdev.boot_device_name = NULL;
if (loader)
- return loader->load_image();
+ return loader->load_image(_image, );
#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,
-