Commit cdbec050 authored by Brian Norris's avatar Brian Norris Committed by David Woodhouse

mtd: nand: fix SCAN2NDPAGE check for BBM

nand_block_bad() doesn't check the correct pages when
NAND_BBT_SCAN2NDPAGE is enabled. It should scan both the OOB region of
both the 1st and 2nd page of each block.
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 00918429
...@@ -338,7 +338,7 @@ static int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) ...@@ -338,7 +338,7 @@ static int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
*/ */
static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
{ {
int page, chipnr, res = 0; int page, chipnr, res = 0, i = 0;
struct nand_chip *chip = mtd->priv; struct nand_chip *chip = mtd->priv;
u16 bad; u16 bad;
...@@ -356,16 +356,18 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) ...@@ -356,16 +356,18 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
chip->select_chip(mtd, chipnr); chip->select_chip(mtd, chipnr);
} }
do {
if (chip->options & NAND_BUSWIDTH_16) { if (chip->options & NAND_BUSWIDTH_16) {
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE, chip->cmdfunc(mtd, NAND_CMD_READOOB,
page); chip->badblockpos & 0xFE, page);
bad = cpu_to_le16(chip->read_word(mtd)); bad = cpu_to_le16(chip->read_word(mtd));
if (chip->badblockpos & 0x1) if (chip->badblockpos & 0x1)
bad >>= 8; bad >>= 8;
else else
bad &= 0xFF; bad &= 0xFF;
} else { } else {
chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page); chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos,
page);
bad = chip->read_byte(mtd); bad = chip->read_byte(mtd);
} }
...@@ -373,6 +375,10 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) ...@@ -373,6 +375,10 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
res = bad != 0xFF; res = bad != 0xFF;
else else
res = hweight8(bad) < chip->badblockbits; res = hweight8(bad) < chip->badblockbits;
ofs += mtd->writesize;
page = (int)(ofs >> chip->page_shift) & chip->pagemask;
i++;
} while (!res && i < 2 && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE));
if (getchip) if (getchip)
nand_release_device(mtd); nand_release_device(mtd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment