Commit 3e66843c authored by Miquel Raynal's avatar Miquel Raynal

mtd: nand: ecc-bch: Use the public nsteps field

The software BCH ECC engine stores the nsteps variable in its own
private structure while it is also exported as a public ECC field.

Let's get rid of the redundant private one and let's use the
nand_ecc_context structure when possible.
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-9-miquel.raynal@bootlin.com
parent 49894937
...@@ -236,7 +236,6 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand) ...@@ -236,7 +236,6 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
goto free_engine_conf; goto free_engine_conf;
engine_conf->code_size = code_size; engine_conf->code_size = code_size;
engine_conf->nsteps = nsteps;
engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL); engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL); engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
if (!engine_conf->calc_buf || !engine_conf->code_buf) { if (!engine_conf->calc_buf || !engine_conf->code_buf) {
...@@ -254,7 +253,7 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand) ...@@ -254,7 +253,7 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
/* Verify the layout validity */ /* Verify the layout validity */
if (mtd_ooblayout_count_eccbytes(mtd) != if (mtd_ooblayout_count_eccbytes(mtd) !=
engine_conf->nsteps * engine_conf->code_size) { nand->ecc.ctx.nsteps * engine_conf->code_size) {
pr_err("Invalid ECC layout\n"); pr_err("Invalid ECC layout\n");
ret = -EINVAL; ret = -EINVAL;
goto cleanup_bch_ctx; goto cleanup_bch_ctx;
...@@ -296,7 +295,7 @@ static int nand_ecc_sw_bch_prepare_io_req(struct nand_device *nand, ...@@ -296,7 +295,7 @@ static int nand_ecc_sw_bch_prepare_io_req(struct nand_device *nand,
struct mtd_info *mtd = nanddev_to_mtd(nand); struct mtd_info *mtd = nanddev_to_mtd(nand);
int eccsize = nand->ecc.ctx.conf.step_size; int eccsize = nand->ecc.ctx.conf.step_size;
int eccbytes = engine_conf->code_size; int eccbytes = engine_conf->code_size;
int eccsteps = engine_conf->nsteps; int eccsteps = nand->ecc.ctx.nsteps;
int total = nand->ecc.ctx.total; int total = nand->ecc.ctx.total;
u8 *ecccalc = engine_conf->calc_buf; u8 *ecccalc = engine_conf->calc_buf;
const u8 *data; const u8 *data;
...@@ -334,7 +333,7 @@ static int nand_ecc_sw_bch_finish_io_req(struct nand_device *nand, ...@@ -334,7 +333,7 @@ static int nand_ecc_sw_bch_finish_io_req(struct nand_device *nand,
int eccsize = nand->ecc.ctx.conf.step_size; int eccsize = nand->ecc.ctx.conf.step_size;
int total = nand->ecc.ctx.total; int total = nand->ecc.ctx.total;
int eccbytes = engine_conf->code_size; int eccbytes = engine_conf->code_size;
int eccsteps = engine_conf->nsteps; int eccsteps = nand->ecc.ctx.nsteps;
u8 *ecccalc = engine_conf->calc_buf; u8 *ecccalc = engine_conf->calc_buf;
u8 *ecccode = engine_conf->code_buf; u8 *ecccode = engine_conf->code_buf;
unsigned int max_bitflips = 0; unsigned int max_bitflips = 0;
...@@ -366,7 +365,7 @@ static int nand_ecc_sw_bch_finish_io_req(struct nand_device *nand, ...@@ -366,7 +365,7 @@ static int nand_ecc_sw_bch_finish_io_req(struct nand_device *nand,
nand_ecc_sw_bch_calculate(nand, data, &ecccalc[i]); nand_ecc_sw_bch_calculate(nand, data, &ecccalc[i]);
/* Finish a page read: compare and correct */ /* Finish a page read: compare and correct */
for (eccsteps = engine_conf->nsteps, i = 0, data = req->databuf.in; for (eccsteps = nand->ecc.ctx.nsteps, i = 0, data = req->databuf.in;
eccsteps; eccsteps;
eccsteps--, i += eccbytes, data += eccsize) { eccsteps--, i += eccbytes, data += eccsize) {
int stat = nand_ecc_sw_bch_correct(nand, data, int stat = nand_ecc_sw_bch_correct(nand, data,
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
* @req_ctx: Save request context and tweak the original request to fit the * @req_ctx: Save request context and tweak the original request to fit the
* engine needs * engine needs
* @code_size: Number of bytes needed to store a code (one code per step) * @code_size: Number of bytes needed to store a code (one code per step)
* @nsteps: Number of steps
* @calc_buf: Buffer to use when calculating ECC bytes * @calc_buf: Buffer to use when calculating ECC bytes
* @code_buf: Buffer to use when reading (raw) ECC bytes from the chip * @code_buf: Buffer to use when reading (raw) ECC bytes from the chip
* @bch: BCH control structure * @bch: BCH control structure
...@@ -26,7 +25,6 @@ ...@@ -26,7 +25,6 @@
struct nand_ecc_sw_bch_conf { struct nand_ecc_sw_bch_conf {
struct nand_ecc_req_tweak_ctx req_ctx; struct nand_ecc_req_tweak_ctx req_ctx;
unsigned int code_size; unsigned int code_size;
unsigned int nsteps;
u8 *calc_buf; u8 *calc_buf;
u8 *code_buf; u8 *code_buf;
struct bch_control *bch; struct bch_control *bch;
......
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