aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-08-30 18:19:40 -0400
committerMark Brown <broonie@linaro.org>2013-08-30 20:31:40 -0400
commita822e99c70f448c4068ea85bb195dac0b2eb3afe (patch)
tree4fd6620e3d1412196acc0142dbf60337c310543f
parentd5ee722ab942451929ccf5bec4fb41f6d044b5c7 (diff)
spi: quad: Make DT properties optional
The addition SPI quad support made the DT properties mandatory, breaking compatibility with existing systems. Fix that by making them optional, also improving the error messages while we're at it. Signed-off-by: Mark Brown <broonie@linaro.org> Tested-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r--drivers/spi/spi.c72
1 files changed, 34 insertions, 38 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f0a6582061d5..7557f611457f 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -871,47 +871,43 @@ static void of_register_spi_devices(struct spi_master *master)
871 871
872 /* Device DUAL/QUAD mode */ 872 /* Device DUAL/QUAD mode */
873 prop = of_get_property(nc, "spi-tx-nbits", &len); 873 prop = of_get_property(nc, "spi-tx-nbits", &len);
874 if (!prop || len < sizeof(*prop)) { 874 if (prop && len == sizeof(*prop)) {
875 dev_err(&master->dev, "%s has no 'spi-tx-nbits' property\n", 875 switch (be32_to_cpup(prop)) {
876 nc->full_name); 876 case SPI_NBITS_SINGLE:
877 spi_dev_put(spi); 877 break;
878 continue; 878 case SPI_NBITS_DUAL:
879 } 879 spi->mode |= SPI_TX_DUAL;
880 switch (be32_to_cpup(prop)) { 880 break;
881 case SPI_NBITS_SINGLE: 881 case SPI_NBITS_QUAD:
882 break; 882 spi->mode |= SPI_TX_QUAD;
883 case SPI_NBITS_DUAL: 883 break;
884 spi->mode |= SPI_TX_DUAL; 884 default:
885 break; 885 dev_err(&master->dev,
886 case SPI_NBITS_QUAD: 886 "spi-tx-nbits %d not supported\n",
887 spi->mode |= SPI_TX_QUAD; 887 be32_to_cpup(prop));
888 break; 888 spi_dev_put(spi);
889 default: 889 continue;
890 dev_err(&master->dev, "spi-tx-nbits value is not supported\n"); 890 }
891 spi_dev_put(spi);
892 continue;
893 } 891 }
894 892
895 prop = of_get_property(nc, "spi-rx-nbits", &len); 893 prop = of_get_property(nc, "spi-rx-nbits", &len);
896 if (!prop || len < sizeof(*prop)) { 894 if (prop && len == sizeof(*prop)) {
897 dev_err(&master->dev, "%s has no 'spi-rx-nbits' property\n", 895 switch (be32_to_cpup(prop)) {
898 nc->full_name); 896 case SPI_NBITS_SINGLE:
899 spi_dev_put(spi); 897 break;
900 continue; 898 case SPI_NBITS_DUAL:
901 } 899 spi->mode |= SPI_RX_DUAL;
902 switch (be32_to_cpup(prop)) { 900 break;
903 case SPI_NBITS_SINGLE: 901 case SPI_NBITS_QUAD:
904 break; 902 spi->mode |= SPI_RX_QUAD;
905 case SPI_NBITS_DUAL: 903 break;
906 spi->mode |= SPI_RX_DUAL; 904 default:
907 break; 905 dev_err(&master->dev,
908 case SPI_NBITS_QUAD: 906 "spi-rx-nbits %d not supported\n",
909 spi->mode |= SPI_RX_QUAD; 907 be32_to_cpup(prop));
910 break; 908 spi_dev_put(spi);
911 default: 909 continue;
912 dev_err(&master->dev, "spi-rx-nbits value is not supported\n"); 910 }
913 spi_dev_put(spi);
914 continue;
915 } 911 }
916 912
917 /* Device speed */ 913 /* Device speed */