mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
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 <michael.hennerich@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
This commit is contained in:
parent
782a895693
commit
73e1ac1625
1 changed files with 8 additions and 5 deletions
|
@ -1108,6 +1108,8 @@ static int bfin_spi_setup(struct spi_device *spi)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chip->chip_select_num >= MAX_CTRL_CS) {
|
if (chip->chip_select_num >= MAX_CTRL_CS) {
|
||||||
|
/* Only request on first setup */
|
||||||
|
if (spi_get_ctldata(spi) == NULL) {
|
||||||
ret = gpio_request(chip->cs_gpio, spi->modalias);
|
ret = gpio_request(chip->cs_gpio, spi->modalias);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&spi->dev, "gpio_request() error\n");
|
dev_err(&spi->dev, "gpio_request() error\n");
|
||||||
|
@ -1115,6 +1117,7 @@ static int bfin_spi_setup(struct spi_device *spi)
|
||||||
}
|
}
|
||||||
gpio_direction_output(chip->cs_gpio, 1);
|
gpio_direction_output(chip->cs_gpio, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dev_dbg(&spi->dev, "setup spi chip %s, width is %d, dma is %d\n",
|
dev_dbg(&spi->dev, "setup spi chip %s, width is %d, dma is %d\n",
|
||||||
spi->modalias, spi->bits_per_word, chip->enable_dma);
|
spi->modalias, spi->bits_per_word, chip->enable_dma);
|
||||||
|
|
Loading…
Add table
Reference in a new issue