diff mbox series

spi: use gpio[d]_set_value_cansleep for setting chipselect GPIO

Message ID 20190209233825.2883-1-linus.walleij@linaro.org
State New
Headers show
Series spi: use gpio[d]_set_value_cansleep for setting chipselect GPIO | expand

Commit Message

Linus Walleij Feb. 9, 2019, 11:38 p.m. UTC
From: Felix Fietkau <nbd@nbd.name>


Sleeping is safe inside spi_transfer_one_message, and some
GPIO chips are running on slow busses (such as I2C GPIO
expanders) and need to sleep for setting values.

Signed-off-by: Felix Fietkau <nbd@nbd.name>

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
This patch was found in the OpenWrt tree, I adapted it for
my recent changes to the SPI core.
---
 drivers/spi/spi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.20.1
diff mbox series

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 2f7176f07591..93986f879b09 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -786,9 +786,10 @@  static void spi_set_cs(struct spi_device *spi, bool enable)
 		 */
 		if (!(spi->mode & SPI_NO_CS)) {
 			if (spi->cs_gpiod)
-				gpiod_set_value(spi->cs_gpiod, !enable);
+				gpiod_set_value_cansleep(spi->cs_gpiod,
+							 !enable);
 			else
-				gpio_set_value(spi->cs_gpio, !enable);
+				gpio_set_value_cansleep(spi->cs_gpio, !enable);
 		}
 		/* Some SPI masters need both GPIO CS & slave_select */
 		if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&