[PATCH v6, 5/8] mtd: m25p80: Let m25p80_read() fallback to spi transfer
Kamal Dasu
kamal.dasu at broadcom.com
Thu Oct 13 14:15:08 PDT 2016
On Mon, Oct 10, 2016 at 4:29 AM, Cyrille Pitchen
<cyrille.pitchen at atmel.com> wrote:
> Hi all,
>
>
> Le 10/10/2016 à 10:04, Florian Fainelli a écrit :
>> On 08/24/2016 03:04 PM, Kamal Dasu wrote:
>>> In m25p80_read() even though spi_flash_read() is supported
>>> by some drivers, under certain circumstances like unaligned
>>> buffer, address or address range limitations on certain SoCs
>>> let it fallback to core spi reads. Such drivers are expected
>>> to return -EAGAIN so that the m25p80_read() uses standard
>>> spi transfer.
>>>
>>> Signed-off-by: Kamal Dasu <kdasu.kdev at gmail.com>
>>
>> MTD folks, any comments on this?
>>
>>> ---
>>> drivers/mtd/devices/m25p80.c | 11 +++++++++--
>>> 1 file changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
>>> index 9cf7fcd..77c2d2c 100644
>>> --- a/drivers/mtd/devices/m25p80.c
>>> +++ b/drivers/mtd/devices/m25p80.c
>>> @@ -155,9 +155,16 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
>>> msg.data_nbits = m25p80_rx_nbits(nor);
>>>
>>> ret = spi_flash_read(spi, &msg);
>>> - if (ret < 0)
>>> +
>>> + if (ret >= 0)
>>> + return msg.retlen;
>>> +
>>> + /*
>>> + * some spi master drivers might need to fallback to
>>> + * normal spi transfer
>>> + */
>>> + if (ret != -EAGAIN)
> I just wonder whether EINVAL would be a better choice.
spi_flash_read calls the down stream controller driver with all
params addresses however accelerated transfer is not possible by the
controller due to alignment issues, it needs to indicate to m25p call
to try the normal transfer, hence use of EAGAIN seemed appropriate.
>>> return ret;
>>> - return msg.retlen;
>>> }
>>>
>>> spi_message_init(&m);
>>>
>>
>
> Best regards,
>
> Cyrille
More information about the linux-mtd
mailing list