NAND: catch read errors when building BBT
authorJon Povey <jon.povey@racelogic.co.uk>
Mon, 17 May 2010 07:15:35 +0000 (16:15 +0900)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 18 May 2010 07:23:48 +0000 (09:23 +0200)
nand_build_bbt() was ignoring the return value from nand_read_page() and
blindly continuing.
It now passes the return value up to the caller if the read fails.

Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk>
src/flash/nand/core.c

index 44b13ce1de85b09124528dca083b7019b133cc95..b3220e2a3b427240c22458464c96ca7d4cf6e377 100644 (file)
@@ -226,6 +226,7 @@ int nand_build_bbt(struct nand_device *nand, int first, int last)
        int i;
        int pages_per_block = (nand->erase_size / nand->page_size);
        uint8_t oob[6];
+       int ret;
 
        if ((first < 0) || (first >= nand->num_blocks))
                first = 0;
@@ -236,7 +237,9 @@ int nand_build_bbt(struct nand_device *nand, int first, int last)
        page = first * pages_per_block;
        for (i = first; i <= last; i++)
        {
-               nand_read_page(nand, page, NULL, 0, oob, 6);
+               ret = nand_read_page(nand, page, NULL, 0, oob, 6);
+               if (ret != ERROR_OK)
+                       return ret;
 
                if (((nand->device->options & NAND_BUSWIDTH_16) && ((oob[0] & oob[1]) != 0xff))
                        || (((nand->page_size == 512) && (oob[5] != 0xff)) ||