linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: core: Ignore unsupported Dual/Quad Transfer Mode bits
@ 2014-04-14 17:39 Geert Uytterhoeven
  2014-04-18 17:26 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2014-04-14 17:39 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, devicetree, linux-sh, linux-kernel, Geert Uytterhoeven

From: Geert Uytterhoeven <geert+renesas@glider.be>

The availability of SPI Dual or Quad Transfer Mode as indicated by the
"spi-tx-bus-width" and "spi-rx-bus-width" properties in the device tree is
a hardware property of the SPI master, SPI slave, and board wiring.  Hence
the SPI core should not reject an SPI slave because an SPI master driver
doesn't (yet) support Dual or Quad Transfer Mode.

Change the lack of Dual or Quad Transfer Mode support in the SPI master
driver from an error condition to a warning condition, and ignore the
unsupported mode bits, falling back to Single Transfer Mode, to avoid
breakages when running old kernels with new device trees.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
I think this should be applied to -stable, for all versions containing
commit f477b7fb13df2b843997559ff34e87d054ba6538 ("spi: DUAL and QUAD
support"), i.e. v3.12, v3.13, v3.14.
---
 drivers/spi/spi.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 4eb9bf02996c..1534fa1dac34 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1756,7 +1756,7 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master);
  */
 int spi_setup(struct spi_device *spi)
 {
-	unsigned	bad_bits;
+	unsigned	bad_bits, ugly_bits;
 	int		status = 0;
 
 	/* check mode to prevent that DUAL and QUAD set at the same time
@@ -1776,6 +1776,15 @@ int spi_setup(struct spi_device *spi)
 	 * that aren't supported with their current master
 	 */
 	bad_bits = spi->mode & ~spi->master->mode_bits;
+	ugly_bits = bad_bits &
+		    (SPI_TX_DUAL | SPI_TX_QUAD | SPI_RX_DUAL | SPI_RX_QUAD);
+	if (ugly_bits) {
+		dev_warn(&spi->dev,
+			 "setup: ignoring unsupported mode bits %x\n",
+			 ugly_bits);
+		spi->mode &= ~ugly_bits;
+		bad_bits &= ~ugly_bits;
+	}
 	if (bad_bits) {
 		dev_err(&spi->dev, "setup: unsupported mode bits %x\n",
 			bad_bits);
-- 
1.7.9.5

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

* Re: [PATCH] spi: core: Ignore unsupported Dual/Quad Transfer Mode bits
  2014-04-14 17:39 [PATCH] spi: core: Ignore unsupported Dual/Quad Transfer Mode bits Geert Uytterhoeven
@ 2014-04-18 17:26 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-04-18 17:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-spi, devicetree, linux-sh, linux-kernel, Geert Uytterhoeven

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

On Mon, Apr 14, 2014 at 07:39:53PM +0200, Geert Uytterhoeven wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> The availability of SPI Dual or Quad Transfer Mode as indicated by the
> "spi-tx-bus-width" and "spi-rx-bus-width" properties in the device tree is
> a hardware property of the SPI master, SPI slave, and board wiring.  Hence
> the SPI core should not reject an SPI slave because an SPI master driver
> doesn't (yet) support Dual or Quad Transfer Mode.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2014-04-18 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-14 17:39 [PATCH] spi: core: Ignore unsupported Dual/Quad Transfer Mode bits Geert Uytterhoeven
2014-04-18 17:26 ` 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).