diff options
author | Brian Norris <computersforpeace@gmail.com> | 2012-01-13 21:11:47 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-03-26 19:11:34 -0400 |
commit | 009184296d957d864d6fa9ac2dd192d29e069878 (patch) | |
tree | 6b5101ac812ba958c94f183eafe112063a835ad0 | |
parent | 152b861622d55f7b17cb6069bd0b275fb559c29a (diff) |
mtd: nand: erase block before marking bad
Many NAND flash systems (especially those with MLC NAND) cannot be
reliably written twice in a row. For instance, when marking a bad block,
the block may already have data written to it, and so we should attempt
to erase the block before writing a bad block marker to its OOB region.
We can ignore erase failures, since the block may be bad such that it
cannot be erased properly; we still attempt to write zeros to its spare
area.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 8a393f9e6027..cd827d5a8255 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -394,6 +394,17 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
394 | uint8_t buf[2] = { 0, 0 }; | 394 | uint8_t buf[2] = { 0, 0 }; |
395 | int block, ret, i = 0; | 395 | int block, ret, i = 0; |
396 | 396 | ||
397 | if (!(chip->bbt_options & NAND_BBT_USE_FLASH)) { | ||
398 | struct erase_info einfo; | ||
399 | |||
400 | /* Attempt erase before marking OOB */ | ||
401 | memset(&einfo, 0, sizeof(einfo)); | ||
402 | einfo.mtd = mtd; | ||
403 | einfo.addr = ofs; | ||
404 | einfo.len = 1 << chip->phys_erase_shift; | ||
405 | nand_erase_nand(mtd, &einfo, 0); | ||
406 | } | ||
407 | |||
397 | if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) | 408 | if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) |
398 | ofs += mtd->erasesize - mtd->writesize; | 409 | ofs += mtd->erasesize - mtd->writesize; |
399 | 410 | ||