Axel Lin 94c69f765f spi: bitbang: Let spi_bitbang_start() take a reference to master
Many drivers that use bitbang library have a leak on probe error paths.
This is because once a spi_master_get() call succeeds, we need an additional
spi_master_put() call to free the memory.

Fix this issue by moving the code taking a reference to master to
spi_bitbang_start(), so spi_bitbang_start() will take a reference to master on
success. With this change, 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.

So now we have below patten for drivers using bitbang library:

probe:
spi_alloc_master        -> Init reference count to 1
spi_bitbang_start       -> Increment reference count
remove:
spi_bitbang_stop        -> Decrement reference count
spi_master_put          -> Decrement reference count (reference count reaches 0)

Fixup all users accordingly.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Suggested-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Acked-by: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17 12:56:14 +01:00
..
2013-09-04 14:41:55 -04:00
2013-09-06 13:30:06 -07:00
2013-09-13 15:09:52 +02:00
2013-09-12 13:04:11 +02:00
2013-09-13 15:09:52 +02:00
2013-09-03 11:37:15 -07:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-12 11:29:26 -07:00
2013-09-09 16:35:29 -07:00
2013-09-06 13:30:06 -07:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-13 15:09:52 +02:00
2013-09-06 13:21:16 -07:00
2013-09-11 15:59:15 -07:00
2013-09-15 17:41:30 -04:00
2013-09-13 15:09:52 +02:00
2013-09-03 11:37:15 -07:00
2013-09-04 11:28:04 -06:00
2013-09-11 19:55:12 -07:00
2013-09-13 15:09:52 +02:00
2013-09-12 11:28:24 -07:00