Skip to content

Commit 048fbdd

Browse files
committed
Revert "mtd: rawnand: tmio: Fix external use of SW Hamming ECC helper"
This reverts commit 6a4c5ad. 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 e7f466c commit 048fbdd

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/mtd/nand/raw/tmio_nand.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <linux/interrupt.h>
3535
#include <linux/ioport.h>
3636
#include <linux/mtd/mtd.h>
37-
#include <linux/mtd/nand-ecc-sw-hamming.h>
3837
#include <linux/mtd/rawnand.h>
3938
#include <linux/mtd/partitions.h>
4039
#include <linux/slab.h>
@@ -293,12 +292,11 @@ static int tmio_nand_correct_data(struct nand_chip *chip, unsigned char *buf,
293292
int r0, r1;
294293

295294
/* assume ecc.size = 512 and ecc.bytes = 6 */
296-
r0 = ecc_sw_hamming_correct(buf, read_ecc, calc_ecc,
297-
chip->ecc.size, false);
295+
r0 = rawnand_sw_hamming_correct(chip, buf, read_ecc, calc_ecc);
298296
if (r0 < 0)
299297
return r0;
300-
r1 = ecc_sw_hamming_correct(buf + 256, read_ecc + 3, calc_ecc + 3,
301-
chip->ecc.size, false);
298+
r1 = rawnand_sw_hamming_correct(chip, buf + 256, read_ecc + 3,
299+
calc_ecc + 3);
302300
if (r1 < 0)
303301
return r1;
304302
return r0 + r1;

0 commit comments

Comments
 (0)