mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gerlando Falauto <gerlando.falauto@keymile.com>
To: linux-kernel@vger.kernel.org
Cc: Gerlando Falauto <gerlando.falauto@keymile.com>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Mark Brown <broonie@kernel.org>
Subject: [PATCH] spi: spi-gpio: Add check for cs-gpios dt property
Date: Wed, 13 Nov 2013 09:02:28 +0100	[thread overview]
Message-ID: <1384329748-2897-1-git-send-email-gerlando.falauto@keymile.com> (raw)

The bindings assumed that the cs-gpios property is always there.
However, a single SPI device can also work fine without an explicit chip select.
Use the SPI_GPIO_NO_CHIPSELECT mode when the property is not present or invaild.

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spi-gpio.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 0021fc4..3f21208 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -463,9 +463,16 @@ static int spi_gpio_probe(struct platform_device *pdev)
 		 * property of the node.
 		 */
 
-		for (i = 0; i < SPI_N_CHIPSEL; i++)
+		for (i = 0; i < SPI_N_CHIPSEL; i++) {
 			spi_gpio->cs_gpios[i] =
 				of_get_named_gpio(np, "cs-gpios", i);
+			if ((SPI_N_CHIPSEL == 1)
+			&& !gpio_is_valid(spi_gpio->cs_gpios[i] < 0)) {
+				dev_info(&pdev->dev,
+					"no cs-gpios property, using no-cs mode\n");
+				spi_gpio->cs_gpios[i] = SPI_GPIO_NO_CHIPSELECT;
+			}
+		}
 	}
 #endif
 
-- 
1.8.0.1


             reply	other threads:[~2013-11-13  8:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13  8:02 Gerlando Falauto [this message]
2013-11-13 13:33 ` Mark Brown
2013-11-13 14:33   ` Gerlando Falauto
2013-11-13 14:57     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384329748-2897-1-git-send-email-gerlando.falauto@keymile.com \
    --to=gerlando.falauto@keymile.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®