From 037bcbc75cc64e49f1093938471f8133b85d082b Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Mon, 22 Feb 2010 20:39:38 +0200 Subject: [PATCH] --- yaml --- r: 195896 b: refs/heads/master c: e0b58d0a7005cd4b9c7fa4694a437a2d86719c13 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/mtd/nand/nand_base.c | 13 +++++++++---- trunk/include/linux/mtd/nand.h | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 788cb6b13270..e0945a90078d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b64d39d8b03fea88417d53715ccbebf71d4dcc9f +refs/heads/master: e0b58d0a7005cd4b9c7fa4694a437a2d86719c13 diff --git a/trunk/drivers/mtd/nand/nand_base.c b/trunk/drivers/mtd/nand/nand_base.c index 51dfea1b3ce6..ba29a29bd743 100644 --- a/trunk/drivers/mtd/nand/nand_base.c +++ b/trunk/drivers/mtd/nand/nand_base.c @@ -364,14 +364,18 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) bad = cpu_to_le16(chip->read_word(mtd)); if (chip->badblockpos & 0x1) bad >>= 8; - if ((bad & 0xFF) != 0xff) - res = 1; + else + bad &= 0xFF; } else { chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page); - if (chip->read_byte(mtd) != 0xff) - res = 1; + bad = chip->read_byte(mtd); } + if (likely(chip->badblockbits == 8)) + res = bad != 0xFF; + else + res = hweight8(bad) < chip->badblockbits; + if (getchip) nand_release_device(mtd); @@ -2884,6 +2888,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, /* Set the bad block position */ chip->badblockpos = mtd->writesize > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; + chip->badblockbits = 8; /* Get chip options, preserve non chip based options */ chip->options &= ~NAND_CHIPOPTIONS_MSK; diff --git a/trunk/include/linux/mtd/nand.h b/trunk/include/linux/mtd/nand.h index 48bc2c54302c..f2d4a1ac14b8 100644 --- a/trunk/include/linux/mtd/nand.h +++ b/trunk/include/linux/mtd/nand.h @@ -401,6 +401,7 @@ struct nand_chip { int subpagesize; uint8_t cellinfo; int badblockpos; + int badblockbits; flstate_t state;