diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-02-08 04:46:14 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-02-15 17:05:58 -0500 |
commit | ea3065df7ddffe4669136619ad712783ccee22c6 (patch) | |
tree | d88eeca492e5de057d3011807715c5d020fba2ba /drivers/spi | |
parent | 1974eba605557e934764cb83c8ceb0eca78f011a (diff) |
spi/bitbang: check for setup_transfer during initialization
setup_transfer is mandatory if spi_bitbang_transfer is used, so
check for it during initialization and not each time during runtime.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi_bitbang.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c index 8b55724d5f39..14a63f6010d1 100644 --- a/drivers/spi/spi_bitbang.c +++ b/drivers/spi/spi_bitbang.c | |||
@@ -259,10 +259,6 @@ static void bitbang_work(struct work_struct *work) | |||
259 | struct spi_bitbang *bitbang = | 259 | struct spi_bitbang *bitbang = |
260 | container_of(work, struct spi_bitbang, work); | 260 | container_of(work, struct spi_bitbang, work); |
261 | unsigned long flags; | 261 | unsigned long flags; |
262 | int (*setup_transfer)(struct spi_device *, | ||
263 | struct spi_transfer *); | ||
264 | |||
265 | setup_transfer = bitbang->setup_transfer; | ||
266 | 262 | ||
267 | spin_lock_irqsave(&bitbang->lock, flags); | 263 | spin_lock_irqsave(&bitbang->lock, flags); |
268 | bitbang->busy = 1; | 264 | bitbang->busy = 1; |
@@ -300,11 +296,7 @@ static void bitbang_work(struct work_struct *work) | |||
300 | 296 | ||
301 | /* init (-1) or override (1) transfer params */ | 297 | /* init (-1) or override (1) transfer params */ |
302 | if (do_setup != 0) { | 298 | if (do_setup != 0) { |
303 | if (!setup_transfer) { | 299 | status = bitbang->setup_transfer(spi, t); |
304 | status = -ENOPROTOOPT; | ||
305 | break; | ||
306 | } | ||
307 | status = setup_transfer(spi, t); | ||
308 | if (status < 0) | 300 | if (status < 0) |
309 | break; | 301 | break; |
310 | if (do_setup == -1) | 302 | if (do_setup == -1) |
@@ -465,6 +457,9 @@ int spi_bitbang_start(struct spi_bitbang *bitbang) | |||
465 | } | 457 | } |
466 | } else if (!bitbang->master->setup) | 458 | } else if (!bitbang->master->setup) |
467 | return -EINVAL; | 459 | return -EINVAL; |
460 | if (bitbang->master->transfer == spi_bitbang_transfer && | ||
461 | !bitbang->setup_transfer) | ||
462 | return -EINVAL; | ||
468 | 463 | ||
469 | /* this task is the only thing to touch the SPI bits */ | 464 | /* this task is the only thing to touch the SPI bits */ |
470 | bitbang->busy = 0; | 465 | bitbang->busy = 0; |