Skip to content

Commit

Permalink
mtd: rawnand: omap2: Use nand_controller_init()
Browse files Browse the repository at this point in the history
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 <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
  • Loading branch information
Boris Brezillon authored and Miquel Raynal committed Feb 5, 2019
1 parent a0916c9 commit efe5d13
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/mtd/nand/raw/omap2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2173,11 +2173,8 @@ static const struct nand_controller_ops omap_nand_controller_ops = {
};

/* Shared among all NAND instances to synchronize access to the ECC Engine */
static struct nand_controller omap_gpmc_controller = {
.lock = __SPIN_LOCK_UNLOCKED(omap_gpmc_controller.lock),
.wq = __WAIT_QUEUE_HEAD_INITIALIZER(omap_gpmc_controller.wq),
.ops = &omap_nand_controller_ops,
};
static struct nand_controller omap_gpmc_controller;
static bool omap_gpmc_controller_initialized;

static int omap_nand_probe(struct platform_device *pdev)
{
Expand Down Expand Up @@ -2227,6 +2224,12 @@ static int omap_nand_probe(struct platform_device *pdev)

info->phys_base = res->start;

if (!omap_gpmc_controller_initialized) {
omap_gpmc_controller.ops = &omap_nand_controller_ops;
nand_controller_init(&omap_gpmc_controller);
omap_gpmc_controller_initialized = true;
}

nand_chip->controller = &omap_gpmc_controller;

nand_chip->legacy.IO_ADDR_W = nand_chip->legacy.IO_ADDR_R;
Expand Down

0 comments on commit efe5d13

Please sign in to comment.