aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_bitbang.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi_bitbang.c')
-rw-r--r--drivers/spi/spi_bitbang.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 85e61f451218..2a5abc08e857 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -188,12 +188,6 @@ int spi_bitbang_setup(struct spi_device *spi)
188 188
189 bitbang = spi_master_get_devdata(spi->master); 189 bitbang = spi_master_get_devdata(spi->master);
190 190
191 /* Bitbangers can support SPI_CS_HIGH, SPI_3WIRE, and so on;
192 * add those to master->flags, and provide the other support.
193 */
194 if ((spi->mode & ~(SPI_CPOL|SPI_CPHA|bitbang->flags)) != 0)
195 return -EINVAL;
196
197 if (!cs) { 191 if (!cs) {
198 cs = kzalloc(sizeof *cs, GFP_KERNEL); 192 cs = kzalloc(sizeof *cs, GFP_KERNEL);
199 if (!cs) 193 if (!cs)
@@ -201,9 +195,6 @@ int spi_bitbang_setup(struct spi_device *spi)
201 spi->controller_state = cs; 195 spi->controller_state = cs;
202 } 196 }
203 197
204 if (!spi->bits_per_word)
205 spi->bits_per_word = 8;
206
207 /* per-word shift register access, in hardware or bitbanging */ 198 /* per-word shift register access, in hardware or bitbanging */
208 cs->txrx_word = bitbang->txrx_word[spi->mode & (SPI_CPOL|SPI_CPHA)]; 199 cs->txrx_word = bitbang->txrx_word[spi->mode & (SPI_CPOL|SPI_CPHA)];
209 if (!cs->txrx_word) 200 if (!cs->txrx_word)
@@ -213,9 +204,7 @@ int spi_bitbang_setup(struct spi_device *spi)
213 if (retval < 0) 204 if (retval < 0)
214 return retval; 205 return retval;
215 206
216 dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n", 207 dev_dbg(&spi->dev, "%s, %u nsec/bit\n", __func__, 2 * cs->nsecs);
217 __func__, spi->mode & (SPI_CPOL | SPI_CPHA),
218 spi->bits_per_word, 2 * cs->nsecs);
219 208
220 /* NOTE we _need_ to call chipselect() early, ideally with adapter 209 /* NOTE we _need_ to call chipselect() early, ideally with adapter
221 * setup, unless the hardware defaults cooperate to avoid confusion 210 * setup, unless the hardware defaults cooperate to avoid confusion
@@ -457,6 +446,9 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
457 spin_lock_init(&bitbang->lock); 446 spin_lock_init(&bitbang->lock);
458 INIT_LIST_HEAD(&bitbang->queue); 447 INIT_LIST_HEAD(&bitbang->queue);
459 448
449 if (!bitbang->master->mode_bits)
450 bitbang->master->mode_bits = SPI_CPOL | SPI_CPHA | bitbang->flags;
451
460 if (!bitbang->master->transfer) 452 if (!bitbang->master->transfer)
461 bitbang->master->transfer = spi_bitbang_transfer; 453 bitbang->master->transfer = spi_bitbang_transfer;
462 if (!bitbang->txrx_bufs) { 454 if (!bitbang->txrx_bufs) {