]> git.baikalelectronics.ru Git - kernel.git/commit
lib/bch: Allow easy bit swapping
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 19 May 2020 07:45:43 +0000 (09:45 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Sun, 24 May 2020 18:48:11 +0000 (20:48 +0200)
commitdf944e635923c7817a046523777f079644df8b73
treecff67a52837088ec35b5c787c182eeb810d3a04f
parent7da1e21a2e11eee8be99285f85ffe12d22efda49
lib/bch: Allow easy bit swapping

It seems that several hardware ECC engine use a swapped representation
of bytes compared to software. This might having to do with how the
ECC engine is wired to the NAND controller or the order the bits are
passed to the hardware BCH logic.

This means that when the software BCH engine is working in conjunction
with data generated with hardware, sometimes we might need to swap the
bits inside bytes, eg:

    0x0A = b0000_1010 -> b0101_0000 = 0x50

Make it possible by adding a boolean to the BCH initialization routine.

Regarding the implementation itself, this is a rather simple approach
that can probably be enhanced in the future by preparing the
->a_{mod,pow}_tab tables with the swapping in mind.

Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200519074549.23673-3-miquel.raynal@bootlin.com
drivers/mtd/devices/docg3.c
drivers/mtd/nand/raw/nand_bch.c
include/linux/bch.h
lib/bch.c