]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Fix the NAND size overflow issue.
authorJason Jin <Jason.jin@freescale.com>
Fri, 19 Sep 2008 09:32:49 +0000 (17:32 +0800)
committerWolfgang Denk <wd@denx.de>
Tue, 14 Oct 2008 11:27:16 +0000 (13:27 +0200)
When the total size of all NAND devices exceeds 4 GiB, the size  will
overflow. This patch tries to fix this.

Note that we still have a problem when a single NAND device 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".

Signed-off-by: Jason Jin <Jason.jin@freescale.com>
Signed-off-by: Wolfgang Denk <wd@denx.de>
drivers/mtd/nand/nand.c

index ebd2acd02bf662bb7e5c614f4897a25a77d867c7..71a0e4bbb1d233f6da96641fc9afe216121e640c 100644 (file)
@@ -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);
 
 #ifdef CFG_NAND_SELECT_DEVICE
        /*