Skip to content

Commit c625823

Browse files
committed
Revert "mtd: rawnand: cs553x: Fix external use of SW Hamming ECC helper"
This reverts commit 56a8d3f. 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 fe972c4 commit c625823

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

drivers/mtd/nand/raw/cs553x_nand.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/module.h>
1919
#include <linux/delay.h>
2020
#include <linux/mtd/mtd.h>
21-
#include <linux/mtd/nand-ecc-sw-hamming.h>
2221
#include <linux/mtd/rawnand.h>
2322
#include <linux/mtd/partitions.h>
2423
#include <linux/iopoll.h>
@@ -241,15 +240,6 @@ static int cs_calculate_ecc(struct nand_chip *this, const u_char *dat,
241240
return 0;
242241
}
243242

244-
static int cs553x_ecc_correct(struct nand_chip *chip,
245-
unsigned char *buf,
246-
unsigned char *read_ecc,
247-
unsigned char *calc_ecc)
248-
{
249-
return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc,
250-
chip->ecc.size, false);
251-
}
252-
253243
static struct cs553x_nand_controller *controllers[4];
254244

255245
static int cs553x_attach_chip(struct nand_chip *chip)
@@ -261,7 +251,7 @@ static int cs553x_attach_chip(struct nand_chip *chip)
261251
chip->ecc.bytes = 3;
262252
chip->ecc.hwctl = cs_enable_hwecc;
263253
chip->ecc.calculate = cs_calculate_ecc;
264-
chip->ecc.correct = cs553x_ecc_correct;
254+
chip->ecc.correct = rawnand_sw_hamming_correct;
265255
chip->ecc.strength = 1;
266256

267257
return 0;

0 commit comments

Comments
 (0)