From: Sascha Hauer Date: Tue, 27 Aug 2019 10:36:53 +0000 (+0200) Subject: mtd: rawnand: omap2: Fix number of bitflips reporting with ELM X-Git-Tag: v5.4-rc1~87^2~13^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f480b969448ee3896f55ef6d037ad4a2df3914bf;p=thirdparty%2Flinux.git mtd: rawnand: omap2: Fix number of bitflips reporting with ELM 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 Signed-off-by: Miquel Raynal --- diff --git a/drivers/mtd/nand/raw/omap2.c b/drivers/mtd/nand/raw/omap2.c index 8d881a28140ef..6ec65f48501c0 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;