diff options
author | Simon Glass <sjg@chromium.org> | 2016-09-24 18:20:13 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-10-06 15:08:52 -0400 |
commit | 2a2ee2ac35f26f6b4dae11a225c2803291dff10e (patch) | |
tree | cdb362cf377e85a635bb54dc7bf7f54991914cd3 /common/spl/spl_nand.c | |
parent | 97d9df0a91f1c68695913518d8dfaf26c41dbb32 (diff) | |
download | u-boot-2a2ee2ac35f26f6b4dae11a225c2803291dff10e.tar.gz |
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>
Diffstat (limited to 'common/spl/spl_nand.c')
-rw-r--r-- | common/spl/spl_nand.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index ed758e518c..5cf712e29a 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 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs, 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 @@ static int spl_nand_load_element(int offset, struct image_header *header) 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 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev) /* 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 @@ static int spl_nand_load_image(struct spl_boot_device *bootdev) } #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 |