summaryrefslogtreecommitdiffstats
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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index 8c11355dec23..0056623dfc6b 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -414,10 +414,16 @@ static int spi_bitbang_unprepare_hardware(struct spi_master *spi)
414 * This routine registers the spi_master, which will process requests in a 414 * This routine registers the spi_master, which will process requests in a
415 * dedicated task, keeping IRQs unblocked most of the time. To stop 415 * dedicated task, keeping IRQs unblocked most of the time. To stop
416 * processing those requests, call spi_bitbang_stop(). 416 * processing those requests, call spi_bitbang_stop().
417 *
418 * On success, this routine will take a reference to master. The caller is
419 * responsible for calling spi_bitbang_stop() to decrement the reference and
420 * spi_master_put() as counterpart of spi_alloc_master() to prevent a memory
421 * leak.
417 */ 422 */
418int spi_bitbang_start(struct spi_bitbang *bitbang) 423int spi_bitbang_start(struct spi_bitbang *bitbang)
419{ 424{
420 struct spi_master *master = bitbang->master; 425 struct spi_master *master = bitbang->master;
426 int ret;
421 427
422 if (!master || !bitbang->chipselect) 428 if (!master || !bitbang->chipselect)
423 return -EINVAL; 429 return -EINVAL;
@@ -449,7 +455,11 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
449 /* driver may get busy before register() returns, especially 455 /* driver may get busy before register() returns, especially
450 * if someone registered boardinfo for devices 456 * if someone registered boardinfo for devices
451 */ 457 */
452 return spi_register_master(master); 458 ret = spi_register_master(spi_master_get(master));
459 if (ret)
460 spi_master_put(master);
461
462 return 0;
453} 463}
454EXPORT_SYMBOL_GPL(spi_bitbang_start); 464EXPORT_SYMBOL_GPL(spi_bitbang_start);
455 465