Revert "mtd: rawnand: cs553x: Fix external use of SW Hamming ECC helper"
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 28 Sep 2021 22:15:07 +0000 (00:15 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 15 Oct 2021 10:21:11 +0000 (12:21 +0200)
commitc625823ad8c095afb9601e06ea9fba07c865f378
treefc4663248416a50aaa4c9282588ada8978da8c7c
parentfe972c458fc561113671dde6bd10198cc7719910
Revert "mtd: rawnand: cs553x: Fix external use of SW Hamming ECC helper"

This reverts commit 56a8d3fd1f342d10ee7b27e9ac0f4d00b5fbb91c.

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/20210413161840.345208-1-miquel.raynal@bootlin.com

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210928221507.199198-9-miquel.raynal@bootlin.com
drivers/mtd/nand/raw/cs553x_nand.c