diff mbox series

mtd: rawnand: omap2: Fix number of bitflips reporting with ELM

Message ID 20190827103653.19263-1-s.hauer@pengutronix.de
State Accepted
Headers show
Series mtd: rawnand: omap2: Fix number of bitflips reporting with ELM | expand

Commit Message

Sascha Hauer Aug. 27, 2019, 10:36 a.m. UTC
omap_elm_correct_data() returns the number of bitflips for the whole
page. This is wrong, it should return the maximum number of bitflips
found in each ecc step.

In my case with a 4k page size NAND mtcdore reported -EUCLEAN with
only 12 bitflips on a page where we could correct up to 128 bits per
page (provided they are distributed equally on the 8 ecc steps)

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/raw/omap2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Miquel Raynal Aug. 29, 2019, 12:47 p.m. UTC | #1
On Tue, 2019-08-27 at 10:36:53 UTC, Sascha Hauer wrote:
> omap_elm_correct_data() returns the number of bitflips for the whole
> page. This is wrong, it should return the maximum number of bitflips
> found in each ecc step.
> 
> In my case with a 4k page size NAND mtcdore reported -EUCLEAN with
> only 12 bitflips on a page where we could correct up to 128 bits per
> page (provided they are distributed equally on the 8 ecc steps)
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/omap2.c b/drivers/mtd/nand/raw/omap2.c
index 8d881a28140e..6ec65f48501c 100644
--- a/drivers/mtd/nand/raw/omap2.c
+++ b/drivers/mtd/nand/raw/omap2.c
@@ -1501,7 +1501,7 @@  static int omap_elm_correct_data(struct nand_chip *chip, u_char *data,
 		}
 
 		/* Update number of correctable errors */
-		stat += err_vec[i].error_count;
+		stat = max_t(unsigned int, stat, err_vec[i].error_count);
 
 		/* Update page data with sector size */
 		data += ecc->size;