[PATCH] mtd: spi-nor: use _lock_and_prep() in _read_sfdp()

Yogesh Gaur yogeshnarayan.gaur at nxp.com
Fri Dec 22 00:35:52 PST 2017


spi_nor_read_sfdp() calls nor->read() to read the SFDP data.
But first needs to call nor->prepare() to prepare the READ command before
calling nor->read().

Patch adds call to spi_nor_lock_and_prep() to prepare the READ command
and add subsequent call to spi_nor_unlock_and_unprep() to release lock
and call nor->unprepare().

Signed-off-by: Yogesh Gaur <yogeshnarayan.gaur at nxp.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 2203d6ef..9fb85ae 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1807,6 +1807,10 @@ static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr,
 	nor->addr_width = 3;
 	nor->read_dummy = 8;
 
+	ret = spi_nor_lock_and_prep(nor, SPI_NOR_OPS_READ);
+	if (ret)
+		goto lock_err;
+
 	while (len) {
 		ret = nor->read(nor, addr, len, (u8 *)buf);
 		if (!ret || ret > len) {
@@ -1822,6 +1826,8 @@ static int spi_nor_read_sfdp(struct spi_nor *nor, u32 addr,
 	}
 	ret = 0;
 
+	spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ);
+lock_err:
 read_err:
 	nor->read_opcode = read_opcode;
 	nor->addr_width = addr_width;
-- 
1.9.1




More information about the linux-mtd mailing list