Hello, The nand_get_device()/nand_release_device() logic looks complex for no obvious reasons. I might be wrong, but I think the spinlock+waitqueue approach can be replaced by regular mutexes: one to serialize accesses to the NAND chip (and protect the suspended field), another one to serialize accesses to the controller. We also get rid of the ->state field which was not really useful except for detecting when the NAND chip is suspended (some drivers were using it to determine the timeout value, but always taking the max timeout sounds like a good solution too, since it's a timeout, not a delay). This ->state field is replaced by a ->suspended field which is protected by the chip lock. So no state machine anymore, just 3 states: 1/ NAND is idle 2/ NAND is being accessed (we don't care about the access type) 3/ NAND is suspended Patches 1 to 4 are preparing things for the chip->state, controller->wq and controller->lock removal by patching all drivers that were accessing those fields directly. Patch 5 is doing the actual locking changes. Note that even if we don't rework the locking, I think patches 1 to 4 are worth applying. Regards, Boris Boris Brezillon (5): mtd: rawnand: mtk: Use nand_controller_init() instead of open-coding it mtd: rawnand: tmio: Do not abuse nand_controller->wq mtd: rawnand: omap2: Use nand_controller_init() mtd: rawnand: Stop using chip->state in drivers mtd: rawnand: Simplify the locking drivers/mtd/nand/raw/mtk_nand.c | 3 +- drivers/mtd/nand/raw/nand_base.c | 111 +++++++++++++------------------ drivers/mtd/nand/raw/omap2.c | 20 +++--- drivers/mtd/nand/raw/r852.c | 3 +- drivers/mtd/nand/raw/tmio_nand.c | 21 +++--- include/linux/mtd/rawnand.h | 24 +++---- 6 files changed, 76 insertions(+), 106 deletions(-) -- 2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/