Skip to content

Commit 8fc6f1f

Browse files
committed
mtd: rawnand: pasemi: 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-16-miquel.raynal@bootlin.com
1 parent 1f65976 commit 8fc6f1f

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

drivers/mtd/nand/raw/pasemi_nand.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
static unsigned int lpcctl;
3131
static struct mtd_info *pasemi_nand_mtd;
32+
static struct nand_controller controller;
3233
static const char driver_name[] = "pasemi-nand";
3334

3435
static void pasemi_read_buf(struct nand_chip *chip, u_char *buf, int len)
@@ -73,6 +74,18 @@ static int pasemi_device_ready(struct nand_chip *chip)
7374
return !!(inl(lpcctl) & LBICTRL_LPCCTL_NR);
7475
}
7576

77+
static int pasemi_attach_chip(struct nand_chip *chip)
78+
{
79+
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
80+
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
81+
82+
return 0;
83+
}
84+
85+
static const struct nand_controller_ops pasemi_ops = {
86+
.attach_chip = pasemi_attach_chip,
87+
};
88+
7689
static int pasemi_nand_probe(struct platform_device *ofdev)
7790
{
7891
struct device *dev = &ofdev->dev;
@@ -100,6 +113,10 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
100113
goto out;
101114
}
102115

116+
controller.ops = &pasemi_ops;
117+
nand_controller_init(&controller);
118+
chip->controller = &controller;
119+
103120
pasemi_nand_mtd = nand_to_mtd(chip);
104121

105122
/* Link the private data with the MTD structure */
@@ -132,8 +149,6 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
132149
chip->legacy.read_buf = pasemi_read_buf;
133150
chip->legacy.write_buf = pasemi_write_buf;
134151
chip->legacy.chip_delay = 0;
135-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
136-
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
137152

138153
/* Enable the following for a flash based bad block table */
139154
chip->bbt_options = NAND_BBT_USE_FLASH;

0 commit comments

Comments
 (0)