diff options
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi_bitbang.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c index 2a5abc08e857..f1db395dd889 100644 --- a/drivers/spi/spi_bitbang.c +++ b/drivers/spi/spi_bitbang.c | |||
@@ -258,6 +258,11 @@ static void bitbang_work(struct work_struct *work) | |||
258 | struct spi_bitbang *bitbang = | 258 | struct spi_bitbang *bitbang = |
259 | container_of(work, struct spi_bitbang, work); | 259 | container_of(work, struct spi_bitbang, work); |
260 | unsigned long flags; | 260 | unsigned long flags; |
261 | int do_setup = -1; | ||
262 | int (*setup_transfer)(struct spi_device *, | ||
263 | struct spi_transfer *); | ||
264 | |||
265 | setup_transfer = bitbang->setup_transfer; | ||
261 | 266 | ||
262 | spin_lock_irqsave(&bitbang->lock, flags); | 267 | spin_lock_irqsave(&bitbang->lock, flags); |
263 | bitbang->busy = 1; | 268 | bitbang->busy = 1; |
@@ -269,8 +274,6 @@ static void bitbang_work(struct work_struct *work) | |||
269 | unsigned tmp; | 274 | unsigned tmp; |
270 | unsigned cs_change; | 275 | unsigned cs_change; |
271 | int status; | 276 | int status; |
272 | int (*setup_transfer)(struct spi_device *, | ||
273 | struct spi_transfer *); | ||
274 | 277 | ||
275 | m = container_of(bitbang->queue.next, struct spi_message, | 278 | m = container_of(bitbang->queue.next, struct spi_message, |
276 | queue); | 279 | queue); |
@@ -287,19 +290,19 @@ static void bitbang_work(struct work_struct *work) | |||
287 | tmp = 0; | 290 | tmp = 0; |
288 | cs_change = 1; | 291 | cs_change = 1; |
289 | status = 0; | 292 | status = 0; |
290 | setup_transfer = NULL; | ||
291 | 293 | ||
292 | list_for_each_entry (t, &m->transfers, transfer_list) { | 294 | list_for_each_entry (t, &m->transfers, transfer_list) { |
293 | 295 | ||
294 | /* override or restore speed and wordsize */ | 296 | /* override speed or wordsize? */ |
295 | if (t->speed_hz || t->bits_per_word) { | 297 | if (t->speed_hz || t->bits_per_word) |
296 | setup_transfer = bitbang->setup_transfer; | 298 | do_setup = 1; |
299 | |||
300 | /* init (-1) or override (1) transfer params */ | ||
301 | if (do_setup != 0) { | ||
297 | if (!setup_transfer) { | 302 | if (!setup_transfer) { |
298 | status = -ENOPROTOOPT; | 303 | status = -ENOPROTOOPT; |
299 | break; | 304 | break; |
300 | } | 305 | } |
301 | } | ||
302 | if (setup_transfer) { | ||
303 | status = setup_transfer(spi, t); | 306 | status = setup_transfer(spi, t); |
304 | if (status < 0) | 307 | if (status < 0) |
305 | break; | 308 | break; |
@@ -363,9 +366,10 @@ static void bitbang_work(struct work_struct *work) | |||
363 | m->status = status; | 366 | m->status = status; |
364 | m->complete(m->context); | 367 | m->complete(m->context); |
365 | 368 | ||
366 | /* restore speed and wordsize */ | 369 | /* restore speed and wordsize if it was overridden */ |
367 | if (setup_transfer) | 370 | if (do_setup == 1) |
368 | setup_transfer(spi, NULL); | 371 | setup_transfer(spi, NULL); |
372 | do_setup = 0; | ||
369 | 373 | ||
370 | /* normally deactivate chipselect ... unless no error and | 374 | /* normally deactivate chipselect ... unless no error and |
371 | * cs_change has hinted that the next message will probably | 375 | * cs_change has hinted that the next message will probably |