Skip to contentSkip to conversation

MTD: OneNAND: Return only negative error codes

PATCH In review Adrian Hunter 3 participants 3 messages Oct 12, 2007 – Oct 14, 2007 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MTD: OneNAND: Return only negative error codes

The OneNAND driver was confusing JFFS2 by returning positive error codes.

---
drivers/mtd/onenand/onenand_base.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/onenand/onenand_base.c +0 -0
index f633941..a8c426b 100644
@@ -327,7 +327,7 @@ static int onenand_wait(struct mtd_info *mtd, int state)
		printk(KERN_ERR "onenand_wait: controller error = 0x%04x\n", ctrl);
		if (ctrl & ONENAND_CTRL_LOCK)
			printk(KERN_ERR "onenand_wait: it's locked error.\n");
-		return ctrl;
+		return -EIO;
	}

	if (interrupt & ONENAND_INT_READ) {
@@ -336,7 +336,7 @@ static int onenand_wait(struct mtd_info *mtd, int state)
			if (ecc & ONENAND_ECC_2BIT_ALL) {
				printk(KERN_ERR "onenand_wait: ECC error = 0x%04x\n", ecc);
				mtd->ecc_stats.failed++;
-				return ecc;
+				return -EBADMSG;
			} else if (ecc & ONENAND_ECC_1BIT_ALL) {
				printk(KERN_INFO "onenand_wait: correctable ECC error = 0x%04x\n", ecc);
				mtd->ecc_stats.corrected++;
Signature · 1 line
1.4.4.2
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines

The OneNAND driver was confusing JFFS2 by returning positive error codes.

It's only possible the write case error and it returns the positive 'ctrl' error. Other case, "2-bit ecc error' is handled with 'mtd->ecc_stat' correctly.

Well, no problem to change to the negative value.

Quoted 29 lines
---
 drivers/mtd/onenand/onenand_base.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/onenand/onenand_base.c +2 -3
index f633941..a8c426b 100644
@@ -327,7 +327,7 @@ static int onenand_wait(struct mtd_info *mtd, int state)
 		printk(KERN_ERR "onenand_wait: controller error = 0x%04x\n", ctrl);
 		if (ctrl & ONENAND_CTRL_LOCK)
 			printk(KERN_ERR "onenand_wait: it's locked error.\n");
-		return ctrl;
+		return -EIO;
 	}
 
 	if (interrupt & ONENAND_INT_READ) {
@@ -336,7 +336,7 @@ static int onenand_wait(struct mtd_info *mtd, int state)
 			if (ecc & ONENAND_ECC_2BIT_ALL) {
 				printk(KERN_ERR "onenand_wait: ECC error = 0x%04x\n", ecc);
 				mtd->ecc_stats.failed++;
-				return ecc;
+				return -EBADMSG;
 			} else if (ecc & ONENAND_ECC_1BIT_ALL) {
 				printk(KERN_INFO "onenand_wait: correctable ECC error = 0x%04x\n", ecc);
 				mtd->ecc_stats.corrected++;
--

1.4.4.2

#2 lore raw
Quoted 9 lines · Kyungmin Park
Quoted 2 lines

The OneNAND driver was confusing JFFS2 by returning positive error codes.

It's only possible the write case error and it returns the positive 'ctrl' error. Other case, "2-bit ecc error' is handled with 'mtd->ecc_stat' correctly.

Well, no problem to change to the negative value.

Yeah, it's rare but we caught this in practice, and JFFS2 just calls BUG() if OneNAND returns positive number while JFFS2 is scanning the flash medium.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)