>From 03acf40c6bcb5231795d2bd5cf6838cfeaaf1c56 Mon Sep 17 00:00:00 2001 From: Matthieu CASTET Date: Fri, 29 Jun 2012 10:36:32 +0200 Subject: [PATCH] add NAND_BBT_SCANALLPAGES support to block_bad --- drivers/mtd/nand/nand_base.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index a11253a..5ed0a9b 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -335,6 +335,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) int page, chipnr, res = 0, i = 0; struct nand_chip *chip = mtd->priv; u16 bad; + int max; if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) ofs += mtd->erasesize - mtd->writesize; @@ -350,6 +351,13 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) chip->select_chip(mtd, chipnr); } + if (chip->bbt_options & NAND_BBT_SCAN2NDPAGE) + max = 2; + else if (chip->bbt_options & NAND_BBT_SCANALLPAGES) + max = 1 << (chip->bbt_erase_shift - chip->page_shift); + else + max = 1; + do { if (chip->options & NAND_BUSWIDTH_16) { chip->cmdfunc(mtd, NAND_CMD_READOOB, @@ -372,7 +380,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) ofs += mtd->writesize; page = (int)(ofs >> chip->page_shift) & chip->pagemask; i++; - } while (!res && i < 2 && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE)); + } while (!res && i < max); if (getchip) nand_release_device(mtd); -- 1.7.10.4