Skip to content

Commit bf3816d

Browse files
committed
mtd: nand: ecc-hamming: Use the public nsteps field
The software Hamming 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: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Adam Ford <aford173@gmail.com> #logicpd Torpedo Link: https://lore.kernel.org/linux-mtd/20210127203020.9574-10-miquel.raynal@bootlin.com
1 parent 3e66843 commit bf3816d

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎drivers/mtd/nand/ecc-sw-hamming.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand)
504504
goto free_engine_conf;
505505

506506
engine_conf->code_size = 3;
507-
engine_conf->nsteps = mtd->writesize / conf->step_size;
508507
engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
509508
engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
510509
if (!engine_conf->calc_buf || !engine_conf->code_buf) {
@@ -514,7 +513,7 @@ int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand)
514513

515514
nand->ecc.ctx.priv = engine_conf;
516515
nand->ecc.ctx.nsteps = mtd->writesize / conf->step_size;
517-
nand->ecc.ctx.total = engine_conf->nsteps * engine_conf->code_size;
516+
nand->ecc.ctx.total = nand->ecc.ctx.nsteps * engine_conf->code_size;
518517

519518
return 0;
520519

@@ -549,7 +548,7 @@ static int nand_ecc_sw_hamming_prepare_io_req(struct nand_device *nand,
549548
struct mtd_info *mtd = nanddev_to_mtd(nand);
550549
int eccsize = nand->ecc.ctx.conf.step_size;
551550
int eccbytes = engine_conf->code_size;
552-
int eccsteps = engine_conf->nsteps;
551+
int eccsteps = nand->ecc.ctx.nsteps;
553552
int total = nand->ecc.ctx.total;
554553
u8 *ecccalc = engine_conf->calc_buf;
555554
const u8 *data;
@@ -587,7 +586,7 @@ static int nand_ecc_sw_hamming_finish_io_req(struct nand_device *nand,
587586
int eccsize = nand->ecc.ctx.conf.step_size;
588587
int total = nand->ecc.ctx.total;
589588
int eccbytes = engine_conf->code_size;
590-
int eccsteps = engine_conf->nsteps;
589+
int eccsteps = nand->ecc.ctx.nsteps;
591590
u8 *ecccalc = engine_conf->calc_buf;
592591
u8 *ecccode = engine_conf->code_buf;
593592
unsigned int max_bitflips = 0;
@@ -619,7 +618,7 @@ static int nand_ecc_sw_hamming_finish_io_req(struct nand_device *nand,
619618
nand_ecc_sw_hamming_calculate(nand, data, &ecccalc[i]);
620619

621620
/* Finish a page read: compare and correct */
622-
for (eccsteps = engine_conf->nsteps, i = 0, data = req->databuf.in;
621+
for (eccsteps = nand->ecc.ctx.nsteps, i = 0, data = req->databuf.in;
623622
eccsteps;
624623
eccsteps--, i += eccbytes, data += eccsize) {
625624
int stat = nand_ecc_sw_hamming_correct(nand, data,

‎include/linux/mtd/nand-ecc-sw-hamming.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
* @req_ctx: Save request context and tweak the original request to fit the
1818
* engine needs
1919
* @code_size: Number of bytes needed to store a code (one code per step)
20-
* @nsteps: Number of steps
2120
* @calc_buf: Buffer to use when calculating ECC bytes
2221
* @code_buf: Buffer to use when reading (raw) ECC bytes from the chip
2322
* @sm_order: Smart Media special ordering
2423
*/
2524
struct nand_ecc_sw_hamming_conf {
2625
struct nand_ecc_req_tweak_ctx req_ctx;
2726
unsigned int code_size;
28-
unsigned int nsteps;
2927
u8 *calc_buf;
3028
u8 *code_buf;
3129
unsigned int sm_order;

0 commit comments

Comments
 (0)