[U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication

Heiko Schocher hs at denx.de
Mon Nov 16 12:50:02 CET 2015


Hello Nikita,

Am 08.11.2015 um 16:11 schrieb Nikita Kiryanov:
> Remove code duplication in spl_nand_load_image().
>
> No functional changes.
>
> Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
> Cc: Scott Wood <scottwood at freescale.com>
> Cc: Igor Grinberg <grinberg at compulab.co.il>
> Acked-by: Scott Wood <scottwood at freescale.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> ---
> Changes in V4:
> 	- No changes.
>
> Changes in V3:
> 	- No changes.
>
> Changes in V2:
> 	- No changes.
>
>   common/spl/spl_nand.c | 31 ++++++++++++++++---------------
>   1 file changed, 16 insertions(+), 15 deletions(-)

Reviewed-by: Heiko Schocher <hs at denx.de>

bye,
Heiko
>
> diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
> index b8c369d..6e4e641 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 *)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
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


More information about the U-Boot mailing list