mtd: nand: ignore ECC errors for simple BBM scans

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Nov 7 11:59:24 EST 2011


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=903cd06cd6ece7f9050a3ad5b03e0b76be2882ff
Commit:     903cd06cd6ece7f9050a3ad5b03e0b76be2882ff
Parent:     51b11e3630672b7ce8793ecf13e5759656edf38a
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Tue Jun 28 16:28:58 2011 -0700
Committer:  Artem Bityutskiy <artem.bityutskiy at intel.com>
CommitDate: Sun Sep 11 15:02:14 2011 +0300

    mtd: nand: ignore ECC errors for simple BBM scans
    
    Now that nand_do_readoob() may return -EUCLEAN or -EBADMSG on ECC errors,
    we need to handle the return value specially in some cases.
    
    When scanning for simple bad block markers, reacting to an ECC error is
    not very useful, as we assume that the relevant markers are still
    non-0xFF for true bad blocks.
    
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Signed-off-by: Artem Bityutskiy <dedekind1 at gmail.com>
---
 drivers/mtd/nand/nand_bbt.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index f30807c..a4fcbf1 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -312,14 +312,20 @@ static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
 			ops.oobbuf = buf + len;
 			ops.datbuf = buf;
 			ops.len = len;
-			return mtd->read_oob(mtd, offs, &ops);
+			res = mtd->read_oob(mtd, offs, &ops);
+
+			/* Ignore ECC errors when checking for BBM */
+			if (res != -EUCLEAN && res != -EBADMSG)
+				return res;
+			return 0;
 		} else {
 			ops.oobbuf = buf + mtd->writesize;
 			ops.datbuf = buf;
 			ops.len = mtd->writesize;
 			res = mtd->read_oob(mtd, offs, &ops);
 
-			if (res)
+			/* Ignore ECC errors when checking for BBM */
+			if (res && res != -EUCLEAN && res != -EBADMSG)
 				return res;
 		}
 
@@ -435,7 +441,8 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
 		 * byte reads for 16 bit buswidth.
 		 */
 		ret = mtd->read_oob(mtd, offs, &ops);
-		if (ret)
+		/* Ignore ECC errors when checking for BBM */
+		if (ret && ret != -EUCLEAN && ret != -EBADMSG)
 			return ret;
 
 		if (check_short_pattern(buf, bd))



More information about the linux-mtd-cvs mailing list