]> git.sur5r.net Git - u-boot/commitdiff
NAND: Really ignore bad blocks when scrubbing
authorMarek Vasut <marek.vasut@gmail.com>
Mon, 12 Sep 2011 04:04:06 +0000 (06:04 +0200)
committerScott Wood <scottwood@freescale.com>
Mon, 3 Oct 2011 23:35:12 +0000 (18:35 -0500)
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
[scottwood@freescale.com: use chip instead of redundant priv_nand]
Signed-off-by: Scott Wood <scottwood@freescale.com>
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/nand_util.c
include/linux/mtd/mtd.h

index e7dfcb1568108194414b8676f6abe780dd4d2a7b..6aac6a2bf4189d8ff64cf5fb344148d8e69a54f7 100644 (file)
@@ -2224,7 +2224,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
                /*
                 * heck if we have a bad block, we do not erase bad blocks !
                 */
-               if (nand_block_checkbad(mtd, ((loff_t) page) <<
+               if (!instr->scrub && nand_block_checkbad(mtd, ((loff_t) page) <<
                                        chip->page_shift, 0, allowbbt)) {
                        printk(KERN_WARNING "nand_erase: attempt to erase a "
                               "bad block at page 0x%08x\n", page);
index 81bf366159e54fcca6057ba59f2d6760091dc0a1..60c778e637018ef350a4c021359ba55b2016032c 100644 (file)
@@ -57,12 +57,6 @@ typedef struct mtd_info        mtd_info_t;
 #define cpu_to_je16(x) (x)
 #define cpu_to_je32(x) (x)
 
-/*****************************************************************************/
-static int nand_block_bad_scrub(struct mtd_info *mtd, loff_t ofs, int getchip)
-{
-       return 0;
-}
-
 /**
  * nand_erase_opts: - erase NAND flash with support for various options
  *                   (jffs2 formating)
@@ -82,7 +76,6 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
        int bbtest = 1;
        int result;
        int percent_complete = -1;
-       int (*nand_block_bad_old)(struct mtd_info *, loff_t, int) = NULL;
        const char *mtd_device = meminfo->name;
        struct mtd_oob_ops oob_opts;
        struct nand_chip *chip = meminfo->priv;
@@ -110,17 +103,15 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
         * and disable bad block table while erasing.
         */
        if (opts->scrub) {
-               struct nand_chip *priv_nand = meminfo->priv;
-
-               nand_block_bad_old = priv_nand->block_bad;
-               priv_nand->block_bad = nand_block_bad_scrub;
-               /* we don't need the bad block table anymore...
+               erase.scrub = opts->scrub;
+               /*
+                * We don't need the bad block table anymore...
                 * after scrub, there are no bad blocks left!
                 */
-               if (priv_nand->bbt) {
-                       kfree(priv_nand->bbt);
+               if (chip->bbt) {
+                       kfree(chip->bbt);
                }
-               priv_nand->bbt = NULL;
+               chip->bbt = NULL;
        }
 
        for (erased_length = 0;
@@ -204,12 +195,8 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
        if (!opts->quiet)
                printf("\n");
 
-       if (nand_block_bad_old) {
-               struct nand_chip *priv_nand = meminfo->priv;
-
-               priv_nand->block_bad = nand_block_bad_old;
-               priv_nand->scan_bbt(meminfo);
-       }
+       if (opts->scrub)
+               chip->scan_bbt(meminfo);
 
        return 0;
 }
index d36d58440abed6c85143d4ad39421a58aa850b54..141c96024c57c5246f967f8e045c2a6abab6c3f9 100644 (file)
@@ -55,6 +55,7 @@ struct erase_info {
        u_long priv;
        u_char state;
        struct erase_info *next;
+       int scrub;
 };
 
 struct mtd_erase_region_info {