diff options
author | Nikita Kiryanov <nikita@compulab.co.il> | 2015-11-08 15:11:42 (GMT) |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-11-18 19:49:34 (GMT) |
commit | 483ab3dc8037878ae5dc7af5f0af7bf7ecc36897 (patch) | |
tree | 4a305b09a5961502bc227d3051798346633a8187 /common/spl | |
parent | 2cb11b35e8b2b21a00b5d1c1c76404cb65d1ceb9 (diff) | |
download | u-boot-483ab3dc8037878ae5dc7af5f0af7bf7ecc36897.tar.xz |
spl: nand: remove code duplication
Remove code duplication in spl_nand_load_image().
No functional changes.
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
[trini: Add back cast to unsigned long of spl_image.load_addr]
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common/spl')
-rw-r--r-- | common/spl/spl_nand.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index b8c369d..302fe9c 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -22,6 +22,19 @@ void spl_nand_load_image(void) nand_deselect(); } #else +static int spl_nand_load_element(int offset, struct image_header *header) +{ + int err; + + err = nand_spl_load_image(offset, sizeof(*header), (void *)header); + if (err) + return err; + + spl_parse_image_header(header); + return nand_spl_load_image(offset, spl_image.size, + (void *)(unsigned long)spl_image.load_addr); +} + void spl_nand_load_image(void) { struct image_header *header; @@ -73,25 +86,13 @@ void spl_nand_load_image(void) } #endif #ifdef CONFIG_NAND_ENV_DST - nand_spl_load_image(CONFIG_ENV_OFFSET, - sizeof(*header), (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size, - (void *)spl_image.load_addr); + spl_nand_load_element(CONFIG_ENV_OFFSET, header); #ifdef CONFIG_ENV_OFFSET_REDUND - nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, - sizeof(*header), (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size, - (void *)spl_image.load_addr); + spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header); #endif #endif /* Load u-boot */ - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - sizeof(*header), (void *)header); - spl_parse_image_header(header); - nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, - spl_image.size, (void *)(unsigned long)spl_image.load_addr); + spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header); nand_deselect(); } #endif |