Skip to content

Commit 1d5f556

Browse files
committed
Revert "mtd: rawnand: sharpsl: Fix external use of SW Hamming ECC helper"
This reverts commit 46fcb57. 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 048fbdd commit 1d5f556

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

drivers/mtd/nand/raw/sharpsl.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/module.h>
1212
#include <linux/delay.h>
1313
#include <linux/mtd/mtd.h>
14-
#include <linux/mtd/nand-ecc-sw-hamming.h>
1514
#include <linux/mtd/rawnand.h>
1615
#include <linux/mtd/partitions.h>
1716
#include <linux/mtd/sharpsl.h>
@@ -97,15 +96,6 @@ static int sharpsl_nand_calculate_ecc(struct nand_chip *chip,
9796
return readb(sharpsl->io + ECCCNTR) != 0;
9897
}
9998

100-
static int sharpsl_nand_correct_ecc(struct nand_chip *chip,
101-
unsigned char *buf,
102-
unsigned char *read_ecc,
103-
unsigned char *calc_ecc)
104-
{
105-
return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc,
106-
chip->ecc.size, false);
107-
}
108-
10999
static int sharpsl_attach_chip(struct nand_chip *chip)
110100
{
111101
if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST)
@@ -116,7 +106,7 @@ static int sharpsl_attach_chip(struct nand_chip *chip)
116106
chip->ecc.strength = 1;
117107
chip->ecc.hwctl = sharpsl_nand_enable_hwecc;
118108
chip->ecc.calculate = sharpsl_nand_calculate_ecc;
119-
chip->ecc.correct = sharpsl_nand_correct_ecc;
109+
chip->ecc.correct = rawnand_sw_hamming_correct;
120110

121111
return 0;
122112
}

0 commit comments

Comments
 (0)