spi: use gpio[d]_set_value_cansleep for setting chipselect GPIO
authorFelix Fietkau <nbd@nbd.name>
Sat, 9 Feb 2019 23:38:25 +0000 (00:38 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 12 Feb 2019 16:41:11 +0000 (16:41 +0000)
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>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c

index 2f7176f075911104c0118d98abc59c9966b4f9bf..93986f879b09ef2a1e46a8ef4932bd8e0c608070 100644 (file)
@@ -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) &&