linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Subject: [PATCH 4/5] spi: Check that Quad/Dual is half duplex
Date: Tue, 21 Jan 2014 16:10:08 +0100	[thread overview]
Message-ID: <1390317009-8292-4-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1390317009-8292-1-git-send-email-geert@linux-m68k.org>

From: Geert Uytterhoeven <geert+renesas@linux-m68k.org>

Quad and Dual SPI Transfers use all available data lines (incl. MOSI/MISO),
hence they must be half duplex. Add a check that verify that.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
---
I think this check is done nowhere else. Please correct me if I missed it.

 drivers/spi/spi.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 7f77f82bf95e..4afcdb4851fa 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1672,6 +1672,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
 		/* check transfer tx/rx_nbits:
 		 * 1. check the value matches one of single, dual and quad
 		 * 2. check tx/rx_nbits match the mode in spi_device
+		 * 3. check dual or quad is half duplex
 		 */
 		if (xfer->tx_buf) {
 			if (xfer->tx_nbits != SPI_NBITS_SINGLE &&
@@ -1684,6 +1685,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
 			if ((xfer->tx_nbits == SPI_NBITS_QUAD) &&
 				!(spi->mode & SPI_TX_QUAD))
 				return -EINVAL;
+			if (xfer->tx_nbits > SPI_NBITS_SINGLE && xfer->rx_buf)
+				return -EINVAL;
 		}
 		/* check transfer rx_nbits */
 		if (xfer->rx_buf) {
@@ -1697,6 +1700,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
 			if ((xfer->rx_nbits == SPI_NBITS_QUAD) &&
 				!(spi->mode & SPI_RX_QUAD))
 				return -EINVAL;
+			if (xfer->rx_nbits > SPI_NBITS_SINGLE && xfer->tx_buf)
+				return -EINVAL;
 		}
 	}
 
-- 
1.7.9.5

  parent reply	other threads:[~2014-01-21 15:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 15:10 [PATCH 1/5] spi: Spelling s/finised/finished/ Geert Uytterhoeven
2014-01-21 15:10 ` [PATCH v2 3/5] spi: Correct set_cs() documentation Geert Uytterhoeven
     [not found]   ` <1390317009-8292-3-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-21 18:13     ` Mark Brown
2014-01-21 15:10 ` Geert Uytterhoeven [this message]
     [not found]   ` <1390317009-8292-4-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-21 18:21     ` [PATCH 4/5] spi: Check that Quad/Dual is half duplex Mark Brown
2014-01-21 20:06       ` Geert Uytterhoeven
     [not found]         ` <CAMuHMdWW1EsHe0u0o8XZuG4AzPKRqKL7ET5Ac2NkbeLRfW_foQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-22 19:19           ` Gerhard Sittig
     [not found]             ` <20140122191947.GQ20094-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2014-01-22 20:26               ` Geert Uytterhoeven
2014-01-22 14:27   ` Geert Uytterhoeven
     [not found] ` <1390317009-8292-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-21 15:10   ` [PATCH v2 2/5] spi: Clarify transfer_one() w.r.t. spi_finalize_current_transfer() Geert Uytterhoeven
     [not found]     ` <1390317009-8292-2-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-21 18:12       ` Mark Brown
2014-01-21 15:10   ` [PATCH 5/5] spi: rspi: Document support for Renesas QSPI in Kconfig Geert Uytterhoeven
     [not found]     ` <1390317009-8292-5-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-21 18:23       ` Mark Brown
2014-01-21 18:12   ` [PATCH 1/5] spi: Spelling s/finised/finished/ Mark Brown

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=1390317009-8292-4-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=broonie@kernel.org \
    --cc=geert+renesas@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /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 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).