diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2013-01-25 03:39:34 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-26 02:35:56 -0500 |
commit | 0202a32d5f4a129ced47db76001f958cd33adeb7 (patch) | |
tree | 563b6db1bc77fac5b0bf02d65130dd0f36191ec7 /drivers/spi/spi-gpio.c | |
parent | 3343b7a6d2cd0a980d0c4a0ce02ef48b6bfcc12a (diff) |
spi: spi-gpio: Add checks for the dt properties
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.ripard@free-electrons.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi-gpio.c')
-rw-r--r-- | drivers/spi/spi-gpio.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index c7cf0b7a069b..9ddef55a7165 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) | |||
365 | if (!pdata) | 365 | if (!pdata) |
366 | return -ENOMEM; | 366 | return -ENOMEM; |
367 | 367 | ||
368 | pdata->sck = of_get_named_gpio(np, "gpio-sck", 0); | 368 | ret = of_get_named_gpio(np, "gpio-sck", 0); |
369 | pdata->miso = of_get_named_gpio(np, "gpio-miso", 0); | 369 | if (ret < 0) { |
370 | pdata->mosi = of_get_named_gpio(np, "gpio-mosi", 0); | 370 | dev_err(&pdev->dev, "gpio-sck property not found\n"); |
371 | goto error_free; | ||
372 | } | ||
373 | pdata->sck = ret; | ||
374 | |||
375 | ret = of_get_named_gpio(np, "gpio-miso", 0); | ||
376 | if (ret < 0) { | ||
377 | dev_info(&pdev->dev, "gpio-miso property not found, switching to no-rx mode\n"); | ||
378 | pdata->miso = SPI_GPIO_NO_MISO; | ||
379 | } else | ||
380 | pdata->miso = ret; | ||
381 | |||
382 | ret = of_get_named_gpio(np, "gpio-mosi", 0); | ||
383 | if (ret < 0) { | ||
384 | dev_info(&pdev->dev, "gpio-mosi property not found, switching to no-tx mode\n"); | ||
385 | pdata->mosi = SPI_GPIO_NO_MOSI; | ||
386 | } else | ||
387 | pdata->mosi = ret; | ||
371 | 388 | ||
372 | ret = of_property_read_u32(np, "num-chipselects", &tmp); | 389 | ret = of_property_read_u32(np, "num-chipselects", &tmp); |
373 | if (ret < 0) { | 390 | if (ret < 0) { |