All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kamal Dasu <kdasu.kdev@gmail.com>
To: cyrille.pitchen@atmel.com, marex@denx.de, broonie@kernel.org
Cc: linux-mtd@lists.infradead.org, f.fainelli@gmail.com,
	bcm-kernel-feedback-list@broadcom.com,
	Kamal Dasu <kdasu.kdev@gmail.com>
Subject: [PATCH, 1/2] mtd: m25p80: Let m25p80_read() fallback to spi transfer
Date: Fri, 20 Jan 2017 16:50:22 -0500	[thread overview]
Message-ID: <1484949023-2085-1-git-send-email-kdasu.kdev@gmail.com> (raw)

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 -EINVAL so that the m25p80_read() uses standard
spi transfer.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
---
 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..7b7f2cc 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 != -EINVAL)
 			return ret;
-		return msg.retlen;
 	}
 
 	spi_message_init(&m);
-- 
1.9.1

             reply	other threads:[~2017-01-20 21:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 21:50 Kamal Dasu [this message]
2017-01-20 21:50 ` [PATCH, 2/2] spi: bcm-qspi: Fix return code from bcm_qspi_flash_read() Kamal Dasu
2017-01-20 22:40   ` Marek Vasut
2017-01-20 22:38 ` [PATCH, 1/2] mtd: m25p80: Let m25p80_read() fallback to spi transfer Marek Vasut
2017-01-20 23:53   ` Michal Suchanek
2017-01-21  0:15     ` Marek Vasut
2017-01-23 23:41       ` Kamal Dasu
2017-01-25  2:08         ` Marek Vasut
2017-01-25  6:29           ` Michal Suchanek
2017-01-25 10:20             ` Marek Vasut
2017-01-25 11:10             ` Cyrille Pitchen
2017-01-25 16:28           ` Kamal Dasu
2017-01-25 16:39             ` Marek Vasut
2017-01-25 17:10               ` Kamal Dasu
2017-01-25 20:17                 ` Marek Vasut
2017-01-29 11:16             ` R, Vignesh
2017-01-30 17:11               ` Kamal Dasu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484949023-2085-1-git-send-email-kdasu.kdev@gmail.com \
    --to=kdasu.kdev@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=broonie@kernel.org \
    --cc=cyrille.pitchen@atmel.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marex@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.