Skip to content

Commit 3c3bbf0

Browse files
committed
mtd: rawnand: txx9ndfmc: Move the ECC initialization to ->attach_chip()
The probe function is only supposed to initialize the controller hardware but not the ECC engine. Indeed, we don't know anything about the NAND chip(s) at this stage. Let's move the logic initializing the ECC engine, even pretty simple, to the ->attach_chip() hook which gets called during nand_scan() routine, after the NAND chip discovery. As the previously mentioned logic is supposed to parse the DT for us, it is likely that the chip->ecc.* entries be overwritten. So let's avoid this by moving these lines to ->attach_chip(). Fixes: d7157ff ("mtd: rawnand: Use the ECC framework user input parsing bits") Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20201113123424.32233-14-miquel.raynal@bootlin.com
1 parent 553508c commit 3c3bbf0

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/mtd/nand/raw/txx9ndfmc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ static int txx9ndfmc_attach_chip(struct nand_chip *chip)
253253
{
254254
struct mtd_info *mtd = nand_to_mtd(chip);
255255

256+
if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST)
257+
return 0;
258+
259+
chip->ecc.strength = 1;
260+
256261
if (mtd->writesize >= 512) {
257262
chip->ecc.size = 512;
258263
chip->ecc.bytes = 6;
@@ -261,6 +266,10 @@ static int txx9ndfmc_attach_chip(struct nand_chip *chip)
261266
chip->ecc.bytes = 3;
262267
}
263268

269+
chip->ecc.calculate = txx9ndfmc_calculate_ecc;
270+
chip->ecc.correct = txx9ndfmc_correct_data;
271+
chip->ecc.hwctl = txx9ndfmc_enable_hwecc;
272+
264273
return 0;
265274
}
266275

@@ -326,11 +335,6 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
326335
chip->legacy.write_buf = txx9ndfmc_write_buf;
327336
chip->legacy.cmd_ctrl = txx9ndfmc_cmd_ctrl;
328337
chip->legacy.dev_ready = txx9ndfmc_dev_ready;
329-
chip->ecc.calculate = txx9ndfmc_calculate_ecc;
330-
chip->ecc.correct = txx9ndfmc_correct_data;
331-
chip->ecc.hwctl = txx9ndfmc_enable_hwecc;
332-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
333-
chip->ecc.strength = 1;
334338
chip->legacy.chip_delay = 100;
335339
chip->controller = &drvdata->controller;
336340

0 commit comments

Comments
 (0)