[U-Boot] [U-boot] [PATCH] env_nand: simplify readenv()

Scott Wood scottwood at freescale.com
Thu May 14 21:11:53 CEST 2015


On Thu, 2015-05-14 at 11:48 -0700, Tim Harvey wrote:
> nand_read_skip_bad() already loops over blocks and handles bad block check
> so eliminate this redundant logic.
> 
> Signed-off-by: Tim Harvey <tharvey at gateworks.com>
> ---
>  common/env_nand.c | 32 ++++++--------------------------
>  1 file changed, 6 insertions(+), 26 deletions(-)
> 
> diff --git a/common/env_nand.c b/common/env_nand.c
> index bab89fd..2036a0e 100644
> --- a/common/env_nand.c
> +++ b/common/env_nand.c
> @@ -268,35 +268,15 @@ static int readenv(size_t offset, u_char *buf)
>  #else
>  static int readenv(size_t offset, u_char *buf)
>  {
> -	size_t end = offset + CONFIG_ENV_RANGE;
> -	size_t amount_loaded = 0;
> -	size_t blocksize, len;
> -	u_char *char_ptr;
> +	nand_info_t *nand = &nand_info[0];
> +	size_t len;
>  
> -	blocksize = nand_info[0].erasesize;
> -	if (!blocksize)
> +	len = CONFIG_ENV_SIZE;
> +	debug("%s: offset=0x%08x len=0x%08x\n", __func__, offset, len);
> +	if (nand_read_skip_bad(nand, offset, &len, NULL, nand->size, buf))
>  		return 1;

The limit should be min(nand->size - offset, CONFIG_ENV_RANGE).

-Scott




More information about the U-Boot mailing list