lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 13 Nov 2013 09:02:28 +0100
From:	Gerlando Falauto <gerlando.falauto@...mile.com>
To:	linux-kernel@...r.kernel.org
Cc:	Gerlando Falauto <gerlando.falauto@...mile.com>,
	Maxime Ripard <maxime.ripard@...e-electrons.com>,
	Mark Brown <broonie@...nel.org>
Subject: [PATCH] spi: spi-gpio: Add check for cs-gpios dt property

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@...mile.com>
Cc: Maxime Ripard <maxime.ripard@...e-electrons.com>
Cc: Mark Brown <broonie@...nel.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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ