spi-nor flash's read/write/erase/lock/unlock may be composed of a set of operations, and some prepare/unprepare works need to be done before/ after these operations in spi_nor_{lock, unlock}_and_{prep, unprep}(). Previously we only call spi-nor controllers' prepare/unprepare method in the functions, without spimem devices'. Add spimem devices' prepare/unprepare support. Call spi_mem_{prepare, unprepare}() function if it's a spimem device. Signed-off-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx> --- drivers/mtd/spi-nor/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index cc68ea8..3a7e40a 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1103,7 +1103,9 @@ int spi_nor_lock_and_prep(struct spi_nor *nor) mutex_lock(&nor->lock); - if (nor->controller_ops && nor->controller_ops->prepare) { + if (nor->spimem) { + ret = spi_mem_prepare(nor->spimem); + } else if (nor->controller_ops && nor->controller_ops->prepare) { ret = nor->controller_ops->prepare(nor); if (ret) { mutex_unlock(&nor->lock); @@ -1115,7 +1117,9 @@ int spi_nor_lock_and_prep(struct spi_nor *nor) void spi_nor_unlock_and_unprep(struct spi_nor *nor) { - if (nor->controller_ops && nor->controller_ops->unprepare) + if (nor->spimem) + spi_mem_unprepare(nor->spimem); + else if (nor->controller_ops && nor->controller_ops->unprepare) nor->controller_ops->unprepare(nor); mutex_unlock(&nor->lock); } -- 2.8.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/