Message ID | CAKekbesG+_9wOuP4HXGKJdK-kmEn443g=vUdyu6Zdn==NO-YHw@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Jun 15, 2016 at 06:56:10PM -0400, Kamal Dasu wrote: > I was looking at spi_flash_read() caled from m25p80_read() and spi > core implementation. I have a case where when we have very small reads > or unaligned buffers and addresses passed then I have to fall back to > using standard MSPI reads. How best to handle this ?. One of the > options without having to replicate code involves a minor change to > m25p80 driver as shown below. That looks reasonable. Another option might be to provide a way for m25p80 to discover the constraints itself. > >> Currently not used. But I did not see a good way to be able to send > >> commands, like finding the ID, setting 3/4 byte addressing mode , quad > >> mode, on a PM resume(). Are you suggesting I make a driver similar to > >> m25p80 ?. > > I am suggesting you implement the standard flash interfaces and as a > > result directly use m25p80. > Are you suggesting to use something like spi_read_then_write() in > cases where I want to set the addressing and single/quad modes ?. Or an explicit series of transfers.
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 9d68544..e98b4fa 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -149,8 +149,11 @@ static int 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); - *retlen = msg.retlen; - return ret; + /* check we need to fallback to normal spi read */ + if (ret != -EAGAIN) { + *retlen = msg.retlen; + return ret; + } }