Patchwork [1/1] omap3: nand: report corrected ecc errors

login
register
mail settings
Submitter John Ogness
Date Feb. 22, 2011, 10:50 a.m.
Message ID <87oc64qr5b.fsf@vostro.fn.ogness.net>
Download mbox | patch
Permalink /patch/83958/
State New
Headers show

Comments

John Ogness - Feb. 22, 2011, 10:50 a.m.
From: John Ogness <john.ogness@linutronix.de>

The number of corrected ECC errors should be reported since other MTD
systems make use of this information (such as UBI data scrubbing).

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
Patch against linux-next-20110221.

 drivers/mtd/nand/omap2.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Artem Bityutskiy - Feb. 25, 2011, 10:59 a.m.
On Tue, 2011-02-22 at 11:50 +0100, John Ogness wrote:
> From: John Ogness <john.ogness@linutronix.de>
> 
> The number of corrected ECC errors should be reported since other MTD
> systems make use of this information (such as UBI data scrubbing).
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Hi, could you please CC the OMAP mailing List
(linux-omap@vger.kernel.org) and probably TI people who seem to take
care about the NAND driver nowadays, like "Sukumar Ghorai
<s-ghorai@ti.com>"


> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index 4e33972..a58465c 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -773,7 +773,7 @@ static int omap_compare_ecc(u8 *ecc_data1,	/* read from NAND memory */
>  
>  		page_data[find_byte] ^= (1 << find_bit);
>  
> -		return 0;
> +		return 1;

Could you please also improve the comment of this function and document
the error codes - it was obvious when the codes were 0 and -1, and
becomes less obvious when they are -1, 0, and 1.

Thanks!

Patch

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 4e33972..a58465c 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -773,7 +773,7 @@  static int omap_compare_ecc(u8 *ecc_data1,	/* read from NAND memory */
 
 		page_data[find_byte] ^= (1 << find_bit);
 
-		return 0;
+		return 1;
 	default:
 		if (isEccFF) {
 			if (ecc_data2[0] == 0 &&
@@ -803,6 +803,7 @@  static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
 	struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
 							mtd);
 	int blockCnt = 0, i = 0, ret = 0;
+	int stat = 0;
 
 	/* Ex NAND_ECC_HW12_2048 */
 	if ((info->nand.ecc.mode == NAND_ECC_HW) &&
@@ -816,12 +817,13 @@  static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
 			ret = omap_compare_ecc(read_ecc, calc_ecc, dat);
 			if (ret < 0)
 				return ret;
+			stat += ret;
 		}
 		read_ecc += 3;
 		calc_ecc += 3;
 		dat      += 512;
 	}
-	return 0;
+	return stat;
 }
 
 /**