devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/2] spi: dual and quad support(device tree)
@ 2013-08-27  0:50 wangyuhang
  2013-08-27  0:50 ` [PATCH V2 2/2] " wangyuhang
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: wangyuhang @ 2013-08-27  0:50 UTC (permalink / raw)
  To: broonie, linux-spi, devicetree, linux-mtd
  Cc: sourav.poddar, pekon, wangyuhang

fix two things in patch:
commit id:f477b7fb13df2b843997559ff34e87d054ba6538

1.change the name of property: spi-tx-nbits and spi-rx-nbits to
spi-tmax-nbits and spi-rmax-nbits, aimed to make that name different
from the member of spi_transfer(tx_nbits and rx_nbits). using tmax
and rmax here to describe that it is the max transfer bits that the
members in spi_transfer(tx_nbits and rx_nbits) can reach.
2.change property spi-tmax-nbits and spi-rmax-nbits to optional.
If User don't set spi-tmax-nbits or spi-rmax-nbits, spi device mode
should be regarded as SINGLE, not return an error. In such case, user
don't have to modify the old dts files to fit the new spi framework.

Signed-off-by: wangyuhang <wangyuhang2014@gmail.com>
---
 drivers/spi/spi.c |   72 +++++++++++++++++++++++++----------------------------
 1 file changed, 34 insertions(+), 38 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 50f7fc3..8d191f2 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -870,48 +870,44 @@ static void of_register_spi_devices(struct spi_master *master)
 			spi->mode |= SPI_3WIRE;
 
 		/* Device DUAL/QUAD mode */
-		prop = of_get_property(nc, "spi-tx-nbits", &len);
+		prop = of_get_property(nc, "spi-tmax-nbits", &len);
 		if (!prop || len < sizeof(*prop)) {
-			dev_err(&master->dev, "%s has no 'spi-tx-nbits' property\n",
-				nc->full_name);
-			spi_dev_put(spi);
-			continue;
-		}
-		switch (be32_to_cpup(prop)) {
-		case SPI_NBITS_SINGLE:
-			break;
-		case SPI_NBITS_DUAL:
-			spi->mode |= SPI_TX_DUAL;
-			break;
-		case SPI_NBITS_QUAD:
-			spi->mode |= SPI_TX_QUAD;
-			break;
-		default:
-			dev_err(&master->dev, "spi-tx-nbits value is not supported\n");
-			spi_dev_put(spi);
-			continue;
+			/* set tx mode in SINGLE as default */
+		} else {
+			switch (be32_to_cpup(prop)) {
+			case SPI_NBITS_SINGLE:
+				break;
+			case SPI_NBITS_DUAL:
+				spi->mode |= SPI_TX_DUAL;
+				break;
+			case SPI_NBITS_QUAD:
+				spi->mode |= SPI_TX_QUAD;
+				break;
+			default:
+				dev_err(&master->dev,
+					"spi-tmax-nbits value is not supported\n");
+				spi_dev_put(spi);
+				continue;
 		}
 
-		prop = of_get_property(nc, "spi-rx-nbits", &len);
+		prop = of_get_property(nc, "spi-rmax-nbits", &len);
 		if (!prop || len < sizeof(*prop)) {
-			dev_err(&master->dev, "%s has no 'spi-rx-nbits' property\n",
-				nc->full_name);
-			spi_dev_put(spi);
-			continue;
-		}
-		switch (be32_to_cpup(prop)) {
-		case SPI_NBITS_SINGLE:
-			break;
-		case SPI_NBITS_DUAL:
-			spi->mode |= SPI_RX_DUAL;
-			break;
-		case SPI_NBITS_QUAD:
-			spi->mode |= SPI_RX_QUAD;
-			break;
-		default:
-			dev_err(&master->dev, "spi-rx-nbits value is not supported\n");
-			spi_dev_put(spi);
-			continue;
+			/* set rx mode in SINGLE as default */
+		} else {
+			switch (be32_to_cpup(prop)) {
+			case SPI_NBITS_SINGLE:
+				break;
+			case SPI_NBITS_DUAL:
+				spi->mode |= SPI_RX_DUAL;
+				break;
+			case SPI_NBITS_QUAD:
+				spi->mode |= SPI_RX_QUAD;
+				break;
+			default:
+				dev_err(&master->dev,
+					"spi-rmax-nbits value is not supported\n");
+				spi_dev_put(spi);
+				continue;
 		}
 
 		/* Device speed */
-- 
1.7.9.5


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2013-09-01  8:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-27  0:50 [PATCH V2 1/2] spi: dual and quad support(device tree) wangyuhang
2013-08-27  0:50 ` [PATCH V2 2/2] " wangyuhang
2013-08-27  4:03   ` Gupta, Pekon
2013-08-30 21:26   ` Stephen Warren
2013-08-30 22:23     ` Mark Brown
2013-09-01  8:05     ` yuhang wang
2013-08-30 21:30   ` Tomasz Figa
2013-09-01  8:14     ` yuhang wang
2013-08-27  4:09 ` [PATCH V2 1/2] " Gupta, Pekon
2013-08-27  4:58   ` yuhang wang
2013-08-27  7:56     ` yuhang wang
2013-08-27  8:37       ` Gupta, Pekon
2013-08-30 21:20 ` Stephen Warren

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).