Skip to content

Commit fe972c4

Browse files
committed
Revert "mtd: rawnand: lpc32xx_slc: Fix external use of SW Hamming ECC helper"
This reverts commit c4b7d7c. Before the introduction of the ECC framework infrastructure, many drivers used the ->calculate/correct() Hamming helpers directly. The point of this framework was to avoid this kind of hackish calls and use a proper and generic API but it is true that in certain cases, drivers still need to use these helpers in order to do ECC computations on behalf of their limited hardware. Right after the introduction of the ECC engine core introduction, it was spotted that it was not possible to use the shiny rawnand software ECC helpers so easily because an ECC engine object should have been allocated and initialized first. While this works well in most cases, for these drivers just leveraging the power of a single helper in conjunction with some pretty old and limited hardware, it did not fit. The idea back then was to declare intermediate helpers which would make use of the exported software ECC engine bare functions while keeping the rawnand layer compatibility. As there was already functions with the rawnand_sw_hamming_ prefix it was decided to declare new local helpers for this purpose in each driver needing one. Besides being far from optimal, this design choice was blamed by Linus when he pulled the "fixes" pull request [1] so that is why now it is time to clean this mess up. The implementation of the rawnand_ecc_sw_* helpers has now been enhanced to support both cases, when the ECC object is instantiated and when it is not. This way, we can still use the existing and exported rawnand helpers while avoiding the need for each driver to declare its own helper, thus this fix from [2] can now be safely reverted. [1] https://lore.kernel.org/lkml/CAHk-=wh_ZHF685Fni8V9is17mj=pFisUaZ_0=gq6nbK+ZcyQmg@mail.gmail.com/ [2] https://lore.kernel.org/linux-mtd/[email protected] Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 8d1e421 commit fe972c4

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

drivers/mtd/nand/raw/lpc32xx_slc.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/of.h>
2828
#include <linux/of_gpio.h>
2929
#include <linux/mtd/lpc32xx_slc.h>
30-
#include <linux/mtd/nand-ecc-sw-hamming.h>
3130

3231
#define LPC32XX_MODNAME "lpc32xx-nand"
3332

@@ -345,18 +344,6 @@ static int lpc32xx_nand_ecc_calculate(struct nand_chip *chip,
345344
return 0;
346345
}
347346

348-
/*
349-
* Corrects the data
350-
*/
351-
static int lpc32xx_nand_ecc_correct(struct nand_chip *chip,
352-
unsigned char *buf,
353-
unsigned char *read_ecc,
354-
unsigned char *calc_ecc)
355-
{
356-
return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc,
357-
chip->ecc.size, false);
358-
}
359-
360347
/*
361348
* Read a single byte from NAND device
362349
*/
@@ -815,7 +802,7 @@ static int lpc32xx_nand_attach_chip(struct nand_chip *chip)
815802
chip->ecc.write_oob = lpc32xx_nand_write_oob_syndrome;
816803
chip->ecc.read_oob = lpc32xx_nand_read_oob_syndrome;
817804
chip->ecc.calculate = lpc32xx_nand_ecc_calculate;
818-
chip->ecc.correct = lpc32xx_nand_ecc_correct;
805+
chip->ecc.correct = rawnand_sw_hamming_correct;
819806
chip->ecc.hwctl = lpc32xx_nand_ecc_enable;
820807

821808
/*

0 commit comments

Comments
 (0)