diff mbox series

[U-Boot,RFC,v2,02/11] spi-mem: Claim SPI bus before spi mem access

Message ID 20181204122659.14720-3-vigneshr@ti.com
State RFC
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series SF: Migrate to Linux SPI NOR framework | expand

Commit Message

Raghavendra, Vignesh Dec. 4, 2018, 12:26 p.m. UTC
It is necessary to call spi_claim_bus() before starting any SPI
transactions and this restriction would also apply when calling spi-mem
operationss. Therefore claim and release bus before requesting transfer
via exec_op.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/spi/spi-mem.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index 1da20b8de5c4..4c1463118ab2 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -231,7 +231,13 @@  int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
 		mutex_lock(&ctlr->bus_lock_mutex);
 		mutex_lock(&ctlr->io_mutex);
 #endif
+		ret = spi_claim_bus(slave);
+		if (ret < 0)
+			return ret;
+
 		ret = ops->mem_ops->exec_op(slave, op);
+
+		spi_release_bus(slave);
 #ifndef __UBOOT__
 		mutex_unlock(&ctlr->io_mutex);
 		mutex_unlock(&ctlr->bus_lock_mutex);