linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: sh-msiof: Fix limit maximum word transfer size of FIFO size
@ 2015-03-12  2:31 Nobuhiro Iwamatsu
  2015-03-12 11:37 ` Mark Brown
  2015-03-12 12:35 ` Geert Uytterhoeven
  0 siblings, 2 replies; 8+ messages in thread
From: Nobuhiro Iwamatsu @ 2015-03-12  2:31 UTC (permalink / raw)
  To: broonie; +Cc: linux-sh, linux-spi, yoshihiro.shimoda.uh, Nobuhiro Iwamatsu

This driver is the case of tx_buf was set or SPI_MASTER_MUST_TX is set to
master_flags, will be transmit mode. However, the current code, when
transmit mode and buffer is NULL, will be set to value of receive mode
size.
This is when the SPI_MASTER_MUST_TX is set to master_flags, sets to
transmit and receive either small size of FIFO, so as not to set the
actual size larger than value of FIFO.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
---
 drivers/spi/spi-sh-msiof.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index e57eec0..260f433 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -606,12 +606,26 @@ static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
 {
 	int fifo_shift;
 	int ret;
+	int rx_words = min_t(int, words, p->rx_fifo_size);
+	int tx_words = min_t(int, words, p->tx_fifo_size);
 
-	/* limit maximum word transfer to rx/tx fifo size */
-	if (tx_buf)
-		words = min_t(int, words, p->tx_fifo_size);
-	if (rx_buf)
-		words = min_t(int, words, p->rx_fifo_size);
+	/*
+	 * limit maximum word transfer to rx/tx fifo size.
+	 *
+	 * If SPI_MASTER_MUST_TX was enabled in master_flags, words was
+	 * set to small value of FIFO.
+	 */
+	if (p->chipdata->master_flags & SPI_MASTER_MUST_TX) {
+		if (rx_words > tx_words)
+			words = tx_words;
+		else
+			words = rx_words;
+	} else {
+		if (tx_buf)
+			words = tx_words;
+		if (rx_buf)
+			words = rx_words;
+	}
 
 	/* the fifo contents need shifting */
 	fifo_shift = 32 - bits;
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-03-18 10:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-12  2:31 [PATCH] spi: sh-msiof: Fix limit maximum word transfer size of FIFO size Nobuhiro Iwamatsu
2015-03-12 11:37 ` Mark Brown
2015-03-12 12:35 ` Geert Uytterhoeven
2015-03-12 16:00   ` Mark Brown
     [not found]   ` <CAMuHMdXmr7QH8jSkyH2q6xCise7ew5YzyAFc6Zb0psHZt3mGrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-16  1:18     ` Nobuhiro Iwamatsu
2015-03-16  7:50       ` Geert Uytterhoeven
2015-03-18  3:50         ` Nobuhiro Iwamatsu
     [not found]           ` <5508F607.7010104-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2015-03-18 10:51             ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).