linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: fsmc: Fix Hamming ECC
@ 2018-09-04  9:14 Boris Brezillon
  2018-09-04 11:42 ` Miquel Raynal
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-09-04  9:14 UTC (permalink / raw)
  To: Boris Brezillon, Richard Weinberger, Miquel Raynal, linux-mtd
  Cc: David Woodhouse, Brian Norris, Marek Vasut, Linus Walleij, stable

Apparently ECC bytes are not ordered as expected by nand_correct_data()
in the ecc_calc buffer which leads to invalid bitflip correction when
an ECC error is detected (can be reproduced with 'nandbiterrs -i').

Re-ordering ECC bytes seems to fix the problem.

While at it, get rid of the useless u8 cast.

Fixes: 6c009ab89a21 ("mtd: generic FSMC NAND MTD driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/mtd/nand/raw/fsmc_nand.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index f418236fa020..c79f8e965b38 100644
--- a/drivers/mtd/nand/raw/fsmc_nand.c
+++ b/drivers/mtd/nand/raw/fsmc_nand.c
@@ -440,9 +440,9 @@ static int fsmc_read_hwecc_ecc1(struct mtd_info *mtd, const uint8_t *data,
 	uint32_t ecc_tmp;
 
 	ecc_tmp = readl_relaxed(host->regs_va + ECC1);
-	ecc[0] = (uint8_t) (ecc_tmp >> 0);
-	ecc[1] = (uint8_t) (ecc_tmp >> 8);
-	ecc[2] = (uint8_t) (ecc_tmp >> 16);
+	ecc[0] = ecc_tmp >> 8;
+	ecc[1] = ecc_tmp;
+	ecc[2] = ecc_tmp >> 16;
 
 	return 0;
 }
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-04 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-04  9:14 [PATCH] mtd: rawnand: fsmc: Fix Hamming ECC Boris Brezillon
2018-09-04 11:42 ` Miquel Raynal
2018-09-04 12:42 ` Linus Walleij
2018-09-04 13:12 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).