[U-Boot] [PATCH 1/4] Fix the NAND size overflow issue.

Wolfgang Denk wd at denx.de
Tue Oct 14 13:27:23 CEST 2008


Dear Jason Jin,

In message <1221816772-23220-1-git-send-email-Jason.jin at freescale.com> you wrote:
> When the NAND size is or large than 4G, the size will overflow,
> The adjustment in this patch try to fix this.
> 
> Signed-off-by: Jason Jin <Jason.jin at freescale.com>
> ---
>  drivers/mtd/nand/nand.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
> index ebd2acd..71a0e4b 100644
> --- a/drivers/mtd/nand/nand.c
> +++ b/drivers/mtd/nand/nand.c
> @@ -63,11 +63,11 @@ void nand_init(void)
>  	unsigned int size = 0;
>  	for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) {
>  		nand_init_chip(&nand_info[i], &nand_chip[i], base_address[i]);
> -		size += nand_info[i].size;
> +		size += nand_info[i].size / 1024;
>  		if (nand_curr_device == -1)
>  			nand_curr_device = i;
>  	}
> -	printf("%u MiB\n", size / (1024 * 1024));
> +	printf("%u MiB\n", size / 1024);

I think the comment is misleading.

Assuming we have a single NAND device that is bigger than 4 GiB, then
the overflow would actually happen earlier, i. e.  when  storing  the
size in nand_info[].size, as nand_info[].size is an "u_int32_t".

So the only situation your patch can fix is when  there  are  several
NAND  devices,  each  of  them smaller than 4 GiB, but the total size
exceeds this limit.

Applied after changing the comment.

Thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I think it's a new feature. Don't tell anyone it was an accident. :-)
  -- Larry Wall on s/foo/bar/eieio in <10911 at jpl-devvax.JPL.NASA.GOV>


More information about the U-Boot mailing list