Re: [PATCH 1/2] spi: spi-gpio: Add checks for the dt properties

2013-01-25 Thread Mark Brown
On Fri, Jan 25, 2013 at 09:39:34AM +0100, Maxime Ripard wrote:
> The bindings assumed that the gpios properties were always there, which
> made the NO_TX and NO_RX mode not usable from device tree. Add extra
> checks to make sure that the driver can work if either MOSI or MISO is
> not used.

Applied, thanks.


signature.asc
Description: Digital signature


[PATCH 1/2] spi: spi-gpio: Add checks for the dt properties

2013-01-25 Thread Maxime Ripard
The bindings assumed that the gpios properties were always there, which
made the NO_TX and NO_RX mode not usable from device tree. Add extra
checks to make sure that the driver can work if either MOSI or MISO is
not used.

Signed-off-by: Maxime Ripard 
Cc: Mark Brown 
---
 drivers/spi/spi-gpio.c |   23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index c7cf0b7..9ddef55 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -365,9 +365,26 @@ static int spi_gpio_probe_dt(struct platform_device *pdev)
if (!pdata)
return -ENOMEM;
 
-   pdata->sck = of_get_named_gpio(np, "gpio-sck", 0);
-   pdata->miso = of_get_named_gpio(np, "gpio-miso", 0);
-   pdata->mosi = of_get_named_gpio(np, "gpio-mosi", 0);
+   ret = of_get_named_gpio(np, "gpio-sck", 0);
+   if (ret < 0) {
+   dev_err(>dev, "gpio-sck property not found\n");
+   goto error_free;
+   }
+   pdata->sck = ret;
+
+   ret = of_get_named_gpio(np, "gpio-miso", 0);
+   if (ret < 0) {
+   dev_info(>dev, "gpio-miso property not found, switching 
to no-rx mode\n");
+   pdata->miso = SPI_GPIO_NO_MISO;
+   } else
+   pdata->miso = ret;
+
+   ret = of_get_named_gpio(np, "gpio-mosi", 0);
+   if (ret < 0) {
+   dev_info(>dev, "gpio-mosi property not found, switching 
to no-tx mode\n");
+   pdata->mosi = SPI_GPIO_NO_MOSI;
+   } else
+   pdata->mosi = ret;
 
ret = of_property_read_u32(np, "num-chipselects", );
if (ret < 0) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] spi: spi-gpio: Add checks for the dt properties

2013-01-25 Thread Maxime Ripard
The bindings assumed that the gpios properties were always there, which
made the NO_TX and NO_RX mode not usable from device tree. Add extra
checks to make sure that the driver can work if either MOSI or MISO is
not used.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
---
 drivers/spi/spi-gpio.c |   23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index c7cf0b7..9ddef55 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -365,9 +365,26 @@ static int spi_gpio_probe_dt(struct platform_device *pdev)
if (!pdata)
return -ENOMEM;
 
-   pdata-sck = of_get_named_gpio(np, gpio-sck, 0);
-   pdata-miso = of_get_named_gpio(np, gpio-miso, 0);
-   pdata-mosi = of_get_named_gpio(np, gpio-mosi, 0);
+   ret = of_get_named_gpio(np, gpio-sck, 0);
+   if (ret  0) {
+   dev_err(pdev-dev, gpio-sck property not found\n);
+   goto error_free;
+   }
+   pdata-sck = ret;
+
+   ret = of_get_named_gpio(np, gpio-miso, 0);
+   if (ret  0) {
+   dev_info(pdev-dev, gpio-miso property not found, switching 
to no-rx mode\n);
+   pdata-miso = SPI_GPIO_NO_MISO;
+   } else
+   pdata-miso = ret;
+
+   ret = of_get_named_gpio(np, gpio-mosi, 0);
+   if (ret  0) {
+   dev_info(pdev-dev, gpio-mosi property not found, switching 
to no-tx mode\n);
+   pdata-mosi = SPI_GPIO_NO_MOSI;
+   } else
+   pdata-mosi = ret;
 
ret = of_property_read_u32(np, num-chipselects, tmp);
if (ret  0) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] spi: spi-gpio: Add checks for the dt properties

2013-01-25 Thread Mark Brown
On Fri, Jan 25, 2013 at 09:39:34AM +0100, Maxime Ripard wrote:
 The bindings assumed that the gpios properties were always there, which
 made the NO_TX and NO_RX mode not usable from device tree. Add extra
 checks to make sure that the driver can work if either MOSI or MISO is
 not used.

Applied, thanks.


signature.asc
Description: Digital signature