summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-bitbang.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-10-25 09:51:18 +0100
committerMark Brown <broonie@linaro.org>2013-10-25 09:51:18 +0100
commit9270d827de92ba638048ff6fad2ba9c01a492ba8 (patch)
treecbc586736137602b2b3c68cfce89126775a22769 /drivers/spi/spi-bitbang.c
parent9fbeace73cb7c7b80de0411b4ba7b879a06e202d (diff)
parent9191546f69ddefe66e46bbe9ba8d1872bc226553 (diff)
Merge remote-tracking branch 'spi/fix/efm' into spi-linus
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 8c11355dec2..0056623dfc6 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)
* This routine registers the spi_master, which will process requests in a
* dedicated task, keeping IRQs unblocked most of the time. To stop
* processing those requests, call spi_bitbang_stop().
+ *
+ * On success, this routine will take a reference to master. The caller is
+ * responsible for calling spi_bitbang_stop() to decrement the reference and
+ * spi_master_put() as counterpart of spi_alloc_master() to prevent a memory
+ * leak.
*/
int spi_bitbang_start(struct spi_bitbang *bitbang)
{
struct spi_master *master = bitbang->master;
+ int ret;
if (!master || !bitbang->chipselect)
return -EINVAL;
@@ -449,7 +455,11 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
/* driver may get busy before register() returns, especially
* if someone registered boardinfo for devices
*/
- return spi_register_master(master);
+ ret = spi_register_master(spi_master_get(master));
+ if (ret)
+ spi_master_put(master);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(spi_bitbang_start);