Skip to content

Commit 73e1ac1

Browse files
mhennerichglikely
authored andcommitted
spi/bfin_spi: only request GPIO on first load
The gpiolib code does not allow people to do gpio_request() on a GPIO once it has already been requested. So make sure we only request the pin on the first setup of a SPI device. Otherwise, if you attempts to reconfigure a SPI device on the fly (like change bit sizes), the setup function incorrectly fails. Signed-off-by: Michael Hennerich <[email protected]> Signed-off-by: Mike Frysinger <[email protected]> Signed-off-by: Grant Likely <[email protected]>
1 parent 782a895 commit 73e1ac1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/spi/spi_bfin5xx.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,15 @@ static int bfin_spi_setup(struct spi_device *spi)
11081108
}
11091109

11101110
if (chip->chip_select_num >= MAX_CTRL_CS) {
1111-
ret = gpio_request(chip->cs_gpio, spi->modalias);
1112-
if (ret) {
1113-
dev_err(&spi->dev, "gpio_request() error\n");
1114-
goto pin_error;
1111+
/* Only request on first setup */
1112+
if (spi_get_ctldata(spi) == NULL) {
1113+
ret = gpio_request(chip->cs_gpio, spi->modalias);
1114+
if (ret) {
1115+
dev_err(&spi->dev, "gpio_request() error\n");
1116+
goto pin_error;
1117+
}
1118+
gpio_direction_output(chip->cs_gpio, 1);
11151119
}
1116-
gpio_direction_output(chip->cs_gpio, 1);
11171120
}
11181121

11191122
dev_dbg(&spi->dev, "setup spi chip %s, width is %d, dma is %d\n",

0 commit comments

Comments
 (0)