Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6dd09f7

Browse files
committed
mtd: rawnand: mpc5121: 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 <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent e044b8b commit 6dd09f7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/mtd/nand/raw/mpc5121_nfc.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
#define NFC_TIMEOUT (HZ / 10) /* 1/10 s */
105105

106106
struct mpc5121_nfc_prv {
107+
struct nand_controller controller;
107108
struct nand_chip chip;
108109
int irq;
109110
void __iomem *regs;
@@ -602,6 +603,18 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd)
602603
iounmap(prv->csreg);
603604
}
604605

606+
static int mpc5121_nfc_attach_chip(struct nand_chip *chip)
607+
{
608+
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
609+
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
610+
611+
return 0;
612+
}
613+
614+
static const struct nand_controller_ops mpc5121_nfc_ops = {
615+
.attach_chip = mpc5121_nfc_attach_chip,
616+
};
617+
605618
static int mpc5121_nfc_probe(struct platform_device *op)
606619
{
607620
struct device_node *dn = op->dev.of_node;
@@ -634,6 +647,10 @@ static int mpc5121_nfc_probe(struct platform_device *op)
634647
chip = &prv->chip;
635648
mtd = nand_to_mtd(chip);
636649

650+
nand_controller_init(&prv->controller);
651+
prv->controller.ops = &mpc5121_nfc_ops;
652+
chip->controller = &prv->controller;
653+
637654
mtd->dev.parent = dev;
638655
nand_set_controller_data(chip, prv);
639656
nand_set_flash_node(chip, dn);
@@ -688,8 +705,6 @@ static int mpc5121_nfc_probe(struct platform_device *op)
688705
chip->legacy.set_features = nand_get_set_features_notsupp;
689706
chip->legacy.get_features = nand_get_set_features_notsupp;
690707
chip->bbt_options = NAND_BBT_USE_FLASH;
691-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
692-
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
693708

694709
/* Support external chip-select logic on ADS5121 board */
695710
if (of_machine_is_compatible("fsl,mpc5121ads")) {

0 commit comments

Comments
 (0)