mtd: rawnand: pasemi: Don't use static data to track per-device state
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 2 Jan 2023 12:40:51 +0000 (13:40 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Sat, 7 Jan 2023 14:19:40 +0000 (15:19 +0100)
commit718004a5972c83cbcc4b649ec34ff314de373650
treec67ac5393b27b1e24f186c11db6e65d3cdd40de1
parent34569d869532b54d6e360d224a0254dcdd6a1785
mtd: rawnand: pasemi: Don't use static data to track per-device state

Up to now the pasemi nand driver only supported a single device
instance. However the check for that was racy because two parallel calls
of pasemi_nand_probe() could pass the check

if (pasemi_nand_mtd)
return -ENODEV;

before any of them assigns a non-NULL value to it.

So rework the driver to make use of per-device driver data.

As an intended side effect the driver can bind more than one device and
also gets rid of the check

if (!pasemi_nand_mtd)
return 0;

in the remove callback that could only ever trigger after the above race
happened.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230102124051.1508424-1-u.kleine-koenig@pengutronix.de
drivers/mtd/nand/raw/pasemi_nand.c