Skip to content

Commit

Permalink
spi/bfin_spi: only request GPIO on first load
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Hennerich authored and Grant Likely committed Oct 22, 2010
1 parent 782a895 commit 73e1ac1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/spi/spi_bfin5xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,12 +1108,15 @@ static int bfin_spi_setup(struct spi_device *spi)
}

if (chip->chip_select_num >= MAX_CTRL_CS) {
ret = gpio_request(chip->cs_gpio, spi->modalias);
if (ret) {
dev_err(&spi->dev, "gpio_request() error\n");
goto pin_error;
/* Only request on first setup */
if (spi_get_ctldata(spi) == NULL) {
ret = gpio_request(chip->cs_gpio, spi->modalias);
if (ret) {
dev_err(&spi->dev, "gpio_request() error\n");
goto pin_error;
}
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",
Expand Down

0 comments on commit 73e1ac1

Please sign in to comment.