Skip to content

Commit 3c97be6

Browse files
committed
mtd: rawnand: nandsim: Fix the logic when selecting Hamming soft ECC engine
I have been fooled by the logic picking the right ECC engine which is spread across two functions: *init_module() and *_attach(). I thought this driver was not impacted by the recent changes around the ECC engines DT parsing logic but in fact it is. Reported-by: kernel test robot <oliver.sang@intel.com> Fixes: d7157ff ("mtd: rawnand: Use the ECC framework user input parsing bits") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20210104093057.31178-1-miquel.raynal@bootlin.com
1 parent 4883a60 commit 3c97be6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

drivers/mtd/nand/raw/nandsim.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,9 @@ static int ns_attach_chip(struct nand_chip *chip)
22102210
{
22112211
unsigned int eccsteps, eccbytes;
22122212

2213+
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
2214+
chip->ecc.algo = bch ? NAND_ECC_ALGO_BCH : NAND_ECC_ALGO_HAMMING;
2215+
22132216
if (!bch)
22142217
return 0;
22152218

@@ -2233,8 +2236,6 @@ static int ns_attach_chip(struct nand_chip *chip)
22332236
return -EINVAL;
22342237
}
22352238

2236-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
2237-
chip->ecc.algo = NAND_ECC_ALGO_BCH;
22382239
chip->ecc.size = 512;
22392240
chip->ecc.strength = bch;
22402241
chip->ecc.bytes = eccbytes;
@@ -2273,8 +2274,6 @@ static int __init ns_init_module(void)
22732274
nsmtd = nand_to_mtd(chip);
22742275
nand_set_controller_data(chip, (void *)ns);
22752276

2276-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
2277-
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
22782277
/* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */
22792278
/* and 'badblocks' parameters to work */
22802279
chip->options |= NAND_SKIP_BBTSCAN;

0 commit comments

Comments
 (0)