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

Skip to content

Commit 553508c

Browse files
committed
mtd: rawnand: orion: 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 6dd09f7 commit 553508c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/mtd/nand/raw/orion_nand.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/platform_data/mtd-orion_nand.h>
2323

2424
struct orion_nand_info {
25+
struct nand_controller controller;
2526
struct nand_chip chip;
2627
struct clk *clk;
2728
};
@@ -82,6 +83,18 @@ static void orion_nand_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
8283
buf[i++] = readb(io_base);
8384
}
8485

86+
static int orion_nand_attach_chip(struct nand_chip *chip)
87+
{
88+
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
89+
chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
90+
91+
return 0;
92+
}
93+
94+
static const struct nand_controller_ops orion_nand_ops = {
95+
.attach_chip = orion_nand_attach_chip,
96+
};
97+
8598
static int __init orion_nand_probe(struct platform_device *pdev)
8699
{
87100
struct orion_nand_info *info;
@@ -101,6 +114,10 @@ static int __init orion_nand_probe(struct platform_device *pdev)
101114
nc = &info->chip;
102115
mtd = nand_to_mtd(nc);
103116

117+
nand_controller_init(&info->controller);
118+
info->controller.ops = &orion_nand_ops;
119+
nc->controller = &info->controller;
120+
104121
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
105122
io_base = devm_ioremap_resource(&pdev->dev, res);
106123

@@ -139,8 +156,6 @@ static int __init orion_nand_probe(struct platform_device *pdev)
139156
nc->legacy.IO_ADDR_R = nc->legacy.IO_ADDR_W = io_base;
140157
nc->legacy.cmd_ctrl = orion_nand_cmd_ctrl;
141158
nc->legacy.read_buf = orion_nand_read_buf;
142-
nc->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
143-
nc->ecc.algo = NAND_ECC_ALGO_HAMMING;
144159

145160
if (board->chip_delay)
146161
nc->legacy.chip_delay = board->chip_delay;

0 commit comments

Comments
 (0)