diff options
author | Chris Zankel <chris@zankel.net> | 2009-04-03 05:29:05 -0400 |
---|---|---|
committer | Chris Zankel <chris@zankel.net> | 2009-04-03 05:29:05 -0400 |
commit | 65127d28e312bb6b38ce84a7bb71d762ef63ad4c (patch) | |
tree | d5fdf52a2d0731f7fab0ce0ed394faac50b04fbc /drivers/spi/spi_gpio.c | |
parent | b8bb76713ec50df2f11efee386e16f93d51e1076 (diff) | |
parent | 8fe74cf053de7ad2124a894996f84fa890a81093 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into merge
Diffstat (limited to 'drivers/spi/spi_gpio.c')
-rw-r--r-- | drivers/spi/spi_gpio.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/spi/spi_gpio.c b/drivers/spi/spi_gpio.c index d2866c293dee..26bd03e61855 100644 --- a/drivers/spi/spi_gpio.c +++ b/drivers/spi/spi_gpio.c | |||
@@ -178,8 +178,10 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active) | |||
178 | if (is_active) | 178 | if (is_active) |
179 | setsck(spi, spi->mode & SPI_CPOL); | 179 | setsck(spi, spi->mode & SPI_CPOL); |
180 | 180 | ||
181 | /* SPI is normally active-low */ | 181 | if (cs != SPI_GPIO_NO_CHIPSELECT) { |
182 | gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); | 182 | /* SPI is normally active-low */ |
183 | gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); | ||
184 | } | ||
183 | } | 185 | } |
184 | 186 | ||
185 | static int spi_gpio_setup(struct spi_device *spi) | 187 | static int spi_gpio_setup(struct spi_device *spi) |
@@ -191,15 +193,17 @@ static int spi_gpio_setup(struct spi_device *spi) | |||
191 | return -EINVAL; | 193 | return -EINVAL; |
192 | 194 | ||
193 | if (!spi->controller_state) { | 195 | if (!spi->controller_state) { |
194 | status = gpio_request(cs, dev_name(&spi->dev)); | 196 | if (cs != SPI_GPIO_NO_CHIPSELECT) { |
195 | if (status) | 197 | status = gpio_request(cs, dev_name(&spi->dev)); |
196 | return status; | 198 | if (status) |
197 | status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH); | 199 | return status; |
200 | status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH); | ||
201 | } | ||
198 | } | 202 | } |
199 | if (!status) | 203 | if (!status) |
200 | status = spi_bitbang_setup(spi); | 204 | status = spi_bitbang_setup(spi); |
201 | if (status) { | 205 | if (status) { |
202 | if (!spi->controller_state) | 206 | if (!spi->controller_state && cs != SPI_GPIO_NO_CHIPSELECT) |
203 | gpio_free(cs); | 207 | gpio_free(cs); |
204 | } | 208 | } |
205 | return status; | 209 | return status; |
@@ -209,7 +213,8 @@ static void spi_gpio_cleanup(struct spi_device *spi) | |||
209 | { | 213 | { |
210 | unsigned long cs = (unsigned long) spi->controller_data; | 214 | unsigned long cs = (unsigned long) spi->controller_data; |
211 | 215 | ||
212 | gpio_free(cs); | 216 | if (cs != SPI_GPIO_NO_CHIPSELECT) |
217 | gpio_free(cs); | ||
213 | spi_bitbang_cleanup(spi); | 218 | spi_bitbang_cleanup(spi); |
214 | } | 219 | } |
215 | 220 | ||