diff mbox series

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

Message ID 20210413161840.345208-5-miquel.raynal@bootlin.com
State Accepted
Commit 3e09c0252501829b14b10f14e1982aaab77d0b80
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/ndfc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Miquel Raynal May 10, 2021, 9:09 a.m. UTC | #1
On Tue, 2021-04-13 at 16:18:37 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/ndfc.c b/drivers/mtd/nand/raw/ndfc.c
index 338d6b1a189e..98d5a94c3a24 100644
--- a/drivers/mtd/nand/raw/ndfc.c
+++ b/drivers/mtd/nand/raw/ndfc.c
@@ -22,6 +22,7 @@ 
 #include <linux/mtd/ndfc.h>
 #include <linux/slab.h>
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/nand-ecc-sw-hamming.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <asm/io.h>
@@ -100,6 +101,15 @@  static int ndfc_calculate_ecc(struct nand_chip *chip,
 	return 0;
 }
 
+static int ndfc_correct_ecc(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);
+}
+
 /*
  * Speedups for buffer read/write/verify
  *
@@ -145,7 +155,7 @@  static int ndfc_chip_init(struct ndfc_controller *ndfc,
 	chip->controller = &ndfc->ndfc_control;
 	chip->legacy.read_buf = ndfc_read_buf;
 	chip->legacy.write_buf = ndfc_write_buf;
-	chip->ecc.correct = rawnand_sw_hamming_correct;
+	chip->ecc.correct = ndfc_correct_ecc;
 	chip->ecc.hwctl = ndfc_enable_hwecc;
 	chip->ecc.calculate = ndfc_calculate_ecc;
 	chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;