Skip to content

Commit efe5d13

Browse files
Boris Brezillonmiquelraynal
authored andcommitted
mtd: rawnand: omap2: Use nand_controller_init()
Stop initializing omap_gpmc_controller fields are declaration time and replace that by a call to nand_controller_init(). Since the same object might be shared by several NAND chips and the NAND controller driver expects a ->probe() per-chip, we need to keep track of the omap_gpmc_controller state (whether it's already been initialized or not). Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent a0916c9 commit efe5d13

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/mtd/nand/raw/omap2.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,11 +2173,8 @@ static const struct nand_controller_ops omap_nand_controller_ops = {
21732173
};
21742174

21752175
/* Shared among all NAND instances to synchronize access to the ECC Engine */
2176-
static struct nand_controller omap_gpmc_controller = {
2177-
.lock = __SPIN_LOCK_UNLOCKED(omap_gpmc_controller.lock),
2178-
.wq = __WAIT_QUEUE_HEAD_INITIALIZER(omap_gpmc_controller.wq),
2179-
.ops = &omap_nand_controller_ops,
2180-
};
2176+
static struct nand_controller omap_gpmc_controller;
2177+
static bool omap_gpmc_controller_initialized;
21812178

21822179
static int omap_nand_probe(struct platform_device *pdev)
21832180
{
@@ -2227,6 +2224,12 @@ static int omap_nand_probe(struct platform_device *pdev)
22272224

22282225
info->phys_base = res->start;
22292226

2227+
if (!omap_gpmc_controller_initialized) {
2228+
omap_gpmc_controller.ops = &omap_nand_controller_ops;
2229+
nand_controller_init(&omap_gpmc_controller);
2230+
omap_gpmc_controller_initialized = true;
2231+
}
2232+
22302233
nand_chip->controller = &omap_gpmc_controller;
22312234

22322235
nand_chip->legacy.IO_ADDR_W = nand_chip->legacy.IO_ADDR_R;

0 commit comments

Comments
 (0)