Commit 49894937 authored by Miquel Raynal's avatar Miquel Raynal

mtd: rawnand: omap: Use ECC information from the generic structures

As part of a previous fix, we imported the BCH internal structure in
order to get information about the BCH engine configuration.

It is best not to access private structure so instead, a small rework
has been done to export more information from the ECC engines. Now,
let's use these.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo
Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-8-miquel.raynal@bootlin.com
parent 5b9215ac
...@@ -1868,18 +1868,19 @@ static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section, ...@@ -1868,18 +1868,19 @@ static int omap_sw_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion) struct mtd_oob_region *oobregion)
{ {
struct nand_device *nand = mtd_to_nanddev(mtd); struct nand_device *nand = mtd_to_nanddev(mtd);
const struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; unsigned int nsteps = nanddev_get_ecc_nsteps(nand);
unsigned int ecc_bytes = nanddev_get_ecc_bytes_per_step(nand);
int off = BADBLOCK_MARKER_LENGTH; int off = BADBLOCK_MARKER_LENGTH;
if (section >= engine_conf->nsteps) if (section >= nsteps)
return -ERANGE; return -ERANGE;
/* /*
* When SW correction is employed, one OMAP specific marker byte is * When SW correction is employed, one OMAP specific marker byte is
* reserved after each ECC step. * reserved after each ECC step.
*/ */
oobregion->offset = off + (section * (engine_conf->code_size + 1)); oobregion->offset = off + (section * (ecc_bytes + 1));
oobregion->length = engine_conf->code_size; oobregion->length = ecc_bytes;
return 0; return 0;
} }
...@@ -1888,7 +1889,8 @@ static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section, ...@@ -1888,7 +1889,8 @@ static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion) struct mtd_oob_region *oobregion)
{ {
struct nand_device *nand = mtd_to_nanddev(mtd); struct nand_device *nand = mtd_to_nanddev(mtd);
const struct nand_ecc_sw_bch_conf *engine_conf = nand->ecc.ctx.priv; unsigned int nsteps = nanddev_get_ecc_nsteps(nand);
unsigned int ecc_bytes = nanddev_get_ecc_bytes_per_step(nand);
int off = BADBLOCK_MARKER_LENGTH; int off = BADBLOCK_MARKER_LENGTH;
if (section) if (section)
...@@ -1898,7 +1900,7 @@ static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section, ...@@ -1898,7 +1900,7 @@ static int omap_sw_ooblayout_free(struct mtd_info *mtd, int section,
* When SW correction is employed, one OMAP specific marker byte is * When SW correction is employed, one OMAP specific marker byte is
* reserved after each ECC step. * reserved after each ECC step.
*/ */
off += ((engine_conf->code_size + 1) * engine_conf->nsteps); off += ((ecc_bytes + 1) * nsteps);
if (off >= mtd->oobsize) if (off >= mtd->oobsize)
return -ERANGE; return -ERANGE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment