[U-Boot] [PATCH v2 01/11] spi-mem: Claim SPI bus before spi mem access

Vignesh R vigneshr at ti.com
Mon Jan 28 09:44:32 UTC 2019



On 28/01/19 12:24 PM, Jagan Teki wrote:
> On Fri, Dec 21, 2018 at 12:08 PM Vignesh R <vigneshr at ti.com> 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 <vigneshr at ti.com>
>> ---
>>  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


More information about the U-Boot mailing list