On Fri, Oct 22, 2010 at 02:01:47AM -0400, Mike Frysinger wrote:
> From: Michael Hennerich <michael.henner...@analog.com>
> 
> 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.henner...@analog.com>
> Signed-off-by: Mike Frysinger <vap...@gentoo.org>

Doesn't that mean that the gpio pin be requested at device probe time
instead of in a function that can be repeatedly called?

g.

> ---
>  drivers/spi/spi_bfin5xx.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
> index ab483a0..a8f276d 100644
> --- a/drivers/spi/spi_bfin5xx.c
> +++ b/drivers/spi/spi_bfin5xx.c
> @@ -1099,12 +1099,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",
> -- 
> 1.7.3.1
> 

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

Reply via email to