[02/14] mtd: nand: do not ignore all ECC errors

Submitted by Brian Norris on Sept. 7, 2011, 8:13 p.m.

Details

Message ID 1315426421-16243-3-git-send-email-computersforpeace@gmail.com
State Accepted
Commit afa17de262633603dd65f89e9370f48e56b8c557
Headers show

Commit Message

Brian Norris Sept. 7, 2011, 8:13 p.m.
There are a few reasons not to ignore ECC errors here.

First, mtd->read_oob is being called in raw mode, so there should be no
error correction in the first place.

Second, if we change this such that there *is* error correction in this
function, then we will want to pass the error message upward.

In fact, the code I introduced to "ignore ECC errors" would have been
better if it had just placed this test down in `scan_block_full()' in
the first place. We would like to ignore ECC errors when we are simply
checking for bad block markers (e.g., factory marked), but we may not
want to ignore ECC errors when scanning OOB for a flash-based BBT
pattern (in `scan_read_raw()'; note that the return codes from
`scan_read_raw()' are not actually handled yet).

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/nand_bbt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Comments

Artem Bityutskiy Sept. 11, 2011, 1:58 p.m.
On Wed, 2011-09-07 at 13:13 -0700, Brian Norris wrote:
> There are a few reasons not to ignore ECC errors here.
> 
> First, mtd->read_oob is being called in raw mode, so there should be no
> error correction in the first place.
> 
> Second, if we change this such that there *is* error correction in this
> function, then we will want to pass the error message upward.
> 
> In fact, the code I introduced to "ignore ECC errors" would have been
> better if it had just placed this test down in `scan_block_full()' in
> the first place. We would like to ignore ECC errors when we are simply
> checking for bad block markers (e.g., factory marked), but we may not
> want to ignore ECC errors when scanning OOB for a flash-based BBT
> pattern (in `scan_read_raw()'; note that the return codes from
> `scan_read_raw()' are not actually handled yet).
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Pushed to my tree, thanks!

Patch hide | download patch | download mbox

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index cbf9b69..fcfaf06 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -313,8 +313,7 @@  static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
 
 		res = mtd->read_oob(mtd, offs, &ops);
 
-		/* Ignore ECC errors when checking for BBM */
-		if (res && res != -EUCLEAN && res != -EBADMSG)
+		if (res)
 			return res;
 
 		buf += mtd->oobsize + mtd->writesize;
@@ -400,7 +399,8 @@  static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
 	int ret, j;
 
 	ret = scan_read_raw_oob(mtd, buf, offs, readlen);
-	if (ret)
+	/* Ignore ECC errors when checking for BBM */
+	if (ret && ret != -EUCLEAN && ret != -EBADMSG)
 		return ret;
 
 	for (j = 0; j < len; j++, buf += scanlen) {