aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/nand/nand_base.c13
-rw-r--r--include/linux/mtd/nand.h1
2 files changed, 10 insertions, 4 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 51dfea1b3ce6..ba29a29bd743 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -364,14 +364,18 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
364 bad = cpu_to_le16(chip->read_word(mtd)); 364 bad = cpu_to_le16(chip->read_word(mtd));
365 if (chip->badblockpos & 0x1) 365 if (chip->badblockpos & 0x1)
366 bad >>= 8; 366 bad >>= 8;
367 if ((bad & 0xFF) != 0xff) 367 else
368 res = 1; 368 bad &= 0xFF;
369 } else { 369 } else {
370 chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page); 370 chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page);
371 if (chip->read_byte(mtd) != 0xff) 371 bad = chip->read_byte(mtd);
372 res = 1;
373 } 372 }
374 373
374 if (likely(chip->badblockbits == 8))
375 res = bad != 0xFF;
376 else
377 res = hweight8(bad) < chip->badblockbits;
378
375 if (getchip) 379 if (getchip)
376 nand_release_device(mtd); 380 nand_release_device(mtd);
377 381
@@ -2884,6 +2888,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2884 /* Set the bad block position */ 2888 /* Set the bad block position */
2885 chip->badblockpos = mtd->writesize > 512 ? 2889 chip->badblockpos = mtd->writesize > 512 ?
2886 NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; 2890 NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
2891 chip->badblockbits = 8;
2887 2892
2888 /* Get chip options, preserve non chip based options */ 2893 /* Get chip options, preserve non chip based options */
2889 chip->options &= ~NAND_CHIPOPTIONS_MSK; 2894 chip->options &= ~NAND_CHIPOPTIONS_MSK;
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 48bc2c54302c..f2d4a1ac14b8 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -401,6 +401,7 @@ struct nand_chip {
401 int subpagesize; 401 int subpagesize;
402 uint8_t cellinfo; 402 uint8_t cellinfo;
403 int badblockpos; 403 int badblockpos;
404 int badblockbits;
404 405
405 flstate_t state; 406 flstate_t state;
406 407