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

Skip to content

Commit d525914

Browse files
committed
mtd: rawnand: xway: 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(), a NAND controller hook. 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 f6341f6 commit d525914

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

drivers/mtd/nand/raw/xway_nand.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#define NAND_CON_NANDM 1
6363

6464
struct xway_nand_data {
65+
struct nand_controller controller;
6566
struct nand_chip chip;
6667
unsigned long csflags;
6768
void __iomem *nandaddr;
@@ -145,6 +146,18 @@ static void xway_write_buf(struct nand_chip *chip, const u_char *buf, int len)
145146
xway_writeb(nand_to_mtd(chip), NAND_WRITE_DATA, buf[i]);
146147
}
147148

149+
static int xway_attach_chip(struct nand_chip *chip)
150+
{
151+
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
152+
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
153+
154+
return 0;
155+
}
156+
157+
static const struct nand_controller_ops xway_nand_ops = {
158+
.attach_chip = xway_attach_chip,
159+
};
160+
148161
/*
149162
* Probe for the NAND device.
150163
*/
@@ -180,8 +193,9 @@ static int xway_nand_probe(struct platform_device *pdev)
180193
data->chip.legacy.read_byte = xway_read_byte;
181194
data->chip.legacy.chip_delay = 30;
182195

183-
data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
184-
data->chip.ecc.algo = NAND_ECC_ALGO_HAMMING;
196+
nand_controller_init(&data->controller);
197+
data->controller.ops = &xway_nand_ops;
198+
data->chip.controller = &data->controller;
185199

186200
platform_set_drvdata(pdev, data);
187201
nand_set_controller_data(&data->chip, data);

0 commit comments

Comments
 (0)