From: Michael Hennerich Date: Fri, 22 Oct 2010 06:01:47 +0000 (-0400) Subject: spi/bfin_spi: only request GPIO on first load X-Git-Tag: firefly_0821_release~7613^2~3525^2~2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=73e1ac16258fe7e55cce4691e32c0b44d4579e08;p=firefly-linux-kernel-4.4.55.git 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 Signed-off-by: Mike Frysinger Signed-off-by: Grant Likely --- diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index d3da41d3f92d..3f223511127b 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c @@ -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",