From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vignesh R Date: Mon, 28 Jan 2019 15:14:32 +0530 Subject: [U-Boot] [PATCH v2 01/11] spi-mem: Claim SPI bus before spi mem access In-Reply-To: References: <20181221063836.11429-1-vigneshr@ti.com> <20181221063836.11429-2-vigneshr@ti.com> Message-ID: <78e16114-95a6-b841-e952-552220a3b7d3@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 28/01/19 12:24 PM, Jagan Teki wrote: > On Fri, Dec 21, 2018 at 12:08 PM Vignesh R wrote: >> >> 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 >> --- >> drivers/spi/spi-mem.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> 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); > > This making spi claims twice, since it's been doing before spi_xfer in > below code. better to make it before the if. > Ok, I will call it from common place -- Regards Vignesh