Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+4 -7
+4 -5
drivers/mtd/nand/ecc-sw-hamming.c
··· 504 504 goto free_engine_conf; 505 505 506 506 engine_conf->code_size = 3; 507 - engine_conf->nsteps = mtd->writesize / conf->step_size; 508 507 engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL); 509 508 engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL); 510 509 if (!engine_conf->calc_buf || !engine_conf->code_buf) { ··· 513 514 514 515 nand->ecc.ctx.priv = engine_conf; 515 516 nand->ecc.ctx.nsteps = mtd->writesize / conf->step_size; 516 - nand->ecc.ctx.total = engine_conf->nsteps * engine_conf->code_size; 517 + nand->ecc.ctx.total = nand->ecc.ctx.nsteps * engine_conf->code_size; 517 518 518 519 return 0; 519 520 ··· 548 549 struct mtd_info *mtd = nanddev_to_mtd(nand); 549 550 int eccsize = nand->ecc.ctx.conf.step_size; 550 551 int eccbytes = engine_conf->code_size; 551 - int eccsteps = engine_conf->nsteps; 552 + int eccsteps = nand->ecc.ctx.nsteps; 552 553 int total = nand->ecc.ctx.total; 553 554 u8 *ecccalc = engine_conf->calc_buf; 554 555 const u8 *data; ··· 586 587 int eccsize = nand->ecc.ctx.conf.step_size; 587 588 int total = nand->ecc.ctx.total; 588 589 int eccbytes = engine_conf->code_size; 589 - int eccsteps = engine_conf->nsteps; 590 + int eccsteps = nand->ecc.ctx.nsteps; 590 591 u8 *ecccalc = engine_conf->calc_buf; 591 592 u8 *ecccode = engine_conf->code_buf; 592 593 unsigned int max_bitflips = 0; ··· 618 619 nand_ecc_sw_hamming_calculate(nand, data, &ecccalc[i]); 619 620 620 621 /* Finish a page read: compare and correct */ 621 - for (eccsteps = engine_conf->nsteps, i = 0, data = req->databuf.in; 622 + for (eccsteps = nand->ecc.ctx.nsteps, i = 0, data = req->databuf.in; 622 623 eccsteps; 623 624 eccsteps--, i += eccbytes, data += eccsize) { 624 625 int stat = nand_ecc_sw_hamming_correct(nand, data,
-2
include/linux/mtd/nand-ecc-sw-hamming.h
··· 17 17 * @req_ctx: Save request context and tweak the original request to fit the 18 18 * engine needs 19 19 * @code_size: Number of bytes needed to store a code (one code per step) 20 - * @nsteps: Number of steps 21 20 * @calc_buf: Buffer to use when calculating ECC bytes 22 21 * @code_buf: Buffer to use when reading (raw) ECC bytes from the chip 23 22 * @sm_order: Smart Media special ordering ··· 24 25 struct nand_ecc_sw_hamming_conf { 25 26 struct nand_ecc_req_tweak_ctx req_ctx; 26 27 unsigned int code_size; 27 - unsigned int nsteps; 28 28 u8 *calc_buf; 29 29 u8 *code_buf; 30 30 unsigned int sm_order;