spi-gpio: init CS before spi_bitbang_setup()
authorJosef Ahmad <josef.ahmad@intel.com>
Tue, 9 Apr 2013 17:25:34 +0000 (18:25 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 10 Apr 2013 13:47:09 +0000 (14:47 +0100)
spi_bitbang_setup() deasserts the chip select line to initialise
the device. The chip select GPIO line is obtained from
spi_gpio->cs_gpios[] private data.
Currently, devices that are not registered under devicetree
environment will call into spi_bitbang_setup() with stale
cs_gpios[].

This patch ensures spi_gpio->cs_gpios[] is always initialised prior
to calling spi_bitbang_setup().

Reviewed-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Josef Ahmad <josef.ahmad@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/spi/spi-gpio.c

index 9ddef55..0021fc4 100644 (file)
@@ -265,9 +265,9 @@ static int spi_gpio_setup(struct spi_device *spi)
                }
        }
        if (!status) {
-               status = spi_bitbang_setup(spi);
                /* in case it was initialized from static board data */
                spi_gpio->cs_gpios[spi->chip_select] = cs;
+               status = spi_bitbang_setup(spi);
        }
 
        if (status) {