Skip to content

Commit 8d1e421

Browse files
committed
Revert "mtd: rawnand: ndfc: Fix external use of SW Hamming ECC helper"
This reverts commit 3e09c02. 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 1d5f556 commit 8d1e421

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

drivers/mtd/nand/raw/ndfc.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/mtd/ndfc.h>
2323
#include <linux/slab.h>
2424
#include <linux/mtd/mtd.h>
25-
#include <linux/mtd/nand-ecc-sw-hamming.h>
2625
#include <linux/of_address.h>
2726
#include <linux/of_platform.h>
2827
#include <asm/io.h>
@@ -101,15 +100,6 @@ static int ndfc_calculate_ecc(struct nand_chip *chip,
101100
return 0;
102101
}
103102

104-
static int ndfc_correct_ecc(struct nand_chip *chip,
105-
unsigned char *buf,
106-
unsigned char *read_ecc,
107-
unsigned char *calc_ecc)
108-
{
109-
return ecc_sw_hamming_correct(buf, read_ecc, calc_ecc,
110-
chip->ecc.size, false);
111-
}
112-
113103
/*
114104
* Speedups for buffer read/write/verify
115105
*
@@ -155,7 +145,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
155145
chip->controller = &ndfc->ndfc_control;
156146
chip->legacy.read_buf = ndfc_read_buf;
157147
chip->legacy.write_buf = ndfc_write_buf;
158-
chip->ecc.correct = ndfc_correct_ecc;
148+
chip->ecc.correct = rawnand_sw_hamming_correct;
159149
chip->ecc.hwctl = ndfc_enable_hwecc;
160150
chip->ecc.calculate = ndfc_calculate_ecc;
161151
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;

0 commit comments

Comments
 (0)