mtd: nand: do not scan BBT after scrub
authorMasahiro Yamada <yamada.m@jp.panasonic.com>
Fri, 26 Dec 2014 13:20:58 +0000 (22:20 +0900)
committerScott Wood <scottwood@freescale.com>
Fri, 9 Jan 2015 18:19:06 +0000 (12:19 -0600)
Currently, "nand scrub" runs chip->scan_bbt at the end of
nand_erase_opts() even if NAND_SKIP_BBTSCAN flag is set.

It violates the intention of NAND_SKIP_BBTSCAN.

Move NAND_SKIP_BBTSCAN flag check to nand_block_checkbad() so that
chip->scan_bbt() is never run if NAND_SKIP_BBTSCAN is set.

Also, unset NAND_BBT_SCANNED flag instead of running chip->scan_bbt()
right after scrub.  We can be lazier here because the BBT is scanned
at the next call of nand_block_checkbad().

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Scott Wood <scottwood@freescale.com>
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/nand_util.c

index eaa4be15069c5ee85cf95ff125b8159013c09574..63bdf65f82c46949bce9fc975a469d3cda86311a 100644 (file)
@@ -634,7 +634,8 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
 {
        struct nand_chip *chip = mtd->priv;
 
-       if (!(chip->options & NAND_BBT_SCANNED)) {
+       if (!(chip->options & NAND_SKIP_BBTSCAN) &&
+           !(chip->options & NAND_BBT_SCANNED)) {
                chip->options |= NAND_BBT_SCANNED;
                chip->scan_bbt(mtd);
        }
@@ -4325,10 +4326,6 @@ int nand_scan_tail(struct mtd_info *mtd)
        if (!mtd->bitflip_threshold)
                mtd->bitflip_threshold = mtd->ecc_strength;
 
-       /* Check, if we should skip the bad block table scan */
-       if (chip->options & NAND_SKIP_BBTSCAN)
-               chip->options |= NAND_BBT_SCANNED;
-
        return 0;
 }
 EXPORT_SYMBOL(nand_scan_tail);
index 024f6fb4402485bc6337a00af308e1eeb5a3e013..afdd160d816a8935671ed5db51ce61424e60b8dd 100644 (file)
@@ -91,6 +91,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
                        kfree(chip->bbt);
                }
                chip->bbt = NULL;
+               chip->options &= ~NAND_BBT_SCANNED;
        }
 
        for (erased_length = 0;
@@ -179,9 +180,6 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
        if (!opts->quiet)
                printf("\n");
 
-       if (opts->scrub)
-               chip->scan_bbt(meminfo);
-
        return 0;
 }