1 Optionally omit the CS signal, if there's only one device on the bus.
7 --- a/drivers/spi/spi_gpio.c
8 +++ b/drivers/spi/spi_gpio.c
9 @@ -178,8 +178,10 @@ static void spi_gpio_chipselect(struct s
11 setsck(spi, spi->mode & SPI_CPOL);
13 - /* SPI is normally active-low */
14 - gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
15 + if (cs != SPI_GPIO_NO_CHIPSELECT) {
16 + /* SPI is normally active-low */
17 + gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
21 static int spi_gpio_setup(struct spi_device *spi)
22 @@ -191,15 +193,17 @@ static int spi_gpio_setup(struct spi_dev
25 if (!spi->controller_state) {
26 - status = gpio_request(cs, spi->dev.bus_id);
29 - status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
30 + if (cs != SPI_GPIO_NO_CHIPSELECT) {
31 + status = gpio_request(cs, spi->dev.bus_id);
34 + status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
38 status = spi_bitbang_setup(spi);
40 - if (!spi->controller_state)
41 + if (!spi->controller_state && cs != SPI_GPIO_NO_CHIPSELECT)
45 @@ -209,7 +213,8 @@ static void spi_gpio_cleanup(struct spi_
47 unsigned long cs = (unsigned long) spi->controller_data;
50 + if (cs != SPI_GPIO_NO_CHIPSELECT)
52 spi_bitbang_cleanup(spi);
55 --- a/include/linux/spi/spi_gpio.h
56 +++ b/include/linux/spi/spi_gpio.h
61 + * If chipselect is not used (there's only one device on the bus), assign
62 + * SPI_GPIO_NO_CHIPSELECT to the controller_data:
63 + * .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT;
65 * If the bitbanged bus is later switched to a "native" controller,
66 * that platform_device and controller_data should be removed.
69 +#define SPI_GPIO_NO_CHIPSELECT ((unsigned long)-1l)
72 * struct spi_gpio_platform_data - parameter for bitbanged SPI master
73 * @sck: number of the GPIO used for clock output