diff mbox series

[v3,1/7] mtd: rawnand: cs553x: Fix external use of SW Hamming ECC helper

Message ID 20210413161840.345208-2-miquel.raynal@bootlin.com
State New
Headers show
Series [v3,1/7] mtd: rawnand: cs553x: Fix external use of SW Hamming ECC helper | expand

Commit Message

Miquel Raynal April 13, 2021, 4:18 p.m. UTC
Since the Hamming software ECC engine has been updated to become a
proper and independent ECC engine, it is now mandatory to either
initialize the engine before using any one of his functions or use one
of the bare helpers which only perform the calculations. As there is no
actual need for a proper ECC initialization, let's just use the bare
helper instead of the rawnand one.

Fixes: 90ccf0a0192f ("mtd: nand: ecc-hamming: Rename the exported functions")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/cs553x_nand.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Miquel Raynal May 10, 2021, 9:09 a.m. UTC | #1
On Tue, 2021-04-13 at 16:18:34 UTC, Miquel Raynal wrote:
> Since the Hamming software ECC engine has been updated to become a

> proper and independent ECC engine, it is now mandatory to either

> initialize the engine before using any one of his functions or use one

> of the bare helpers which only perform the calculations. As there is no

> actual need for a proper ECC initialization, let's just use the bare

> helper instead of the rawnand one.

> 

> Fixes: 90ccf0a0192f ("mtd: nand: ecc-hamming: Rename the exported functions")

> Cc: stable@vger.kernel.org

> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>


Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes.

Miquel
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/cs553x_nand.c b/drivers/mtd/nand/raw/cs553x_nand.c
index 6edf78c16fc8..3e41d815d5b0 100644
--- a/drivers/mtd/nand/raw/cs553x_nand.c
+++ b/drivers/mtd/nand/raw/cs553x_nand.c
@@ -240,6 +240,15 @@  static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,
 	return 0;
 }
 
+static int cs553x_ecc_correct(struct nand_chip *chip,
+			      unsigned char *buf,
+			      unsigned char *read_ecc,
+			      unsigned char *calc_ecc)
+{
+	return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc,
+				      chip->ecc.size, false);
+}
+
 static struct cs553x_nand_controller *controllers[4];
 
 static int cs553x_attach_chip(struct nand_chip *chip)
@@ -251,7 +260,7 @@  static int cs553x_attach_chip(struct nand_chip *chip)
 	chip->ecc.bytes = 3;
 	chip->ecc.hwctl  = cs_enable_hwecc;
 	chip->ecc.calculate = cs_calculate_ecc;
-	chip->ecc.correct  = rawnand_sw_hamming_correct;
+	chip->ecc.correct  = cs553x_ecc_correct;
 	chip->ecc.strength = 1;
 
 	return 0;