diff options
author | Roman Tereshonkov <roman.tereshonkov@nokia.com> | 2010-04-16 05:52:59 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-04-28 03:14:05 -0400 |
commit | 8ec130a017ebd8b931344edde7013ffb18fa1965 (patch) | |
tree | 183138a6db30ce3f002c65cae7304c27927edaa9 /drivers/spi/spi.c | |
parent | 9bd73715a1f83f640937c121d22fa8dbaab73002 (diff) |
spi: release device claimed by bus_find_device_by_name
In success case the function bus_find_device_by_name calls
get_device. In our context put_device should be called to
decrease the device count usage.
Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 9ffb0fdbd6fe..ec429d156a57 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -257,6 +257,7 @@ int spi_add_device(struct spi_device *spi) | |||
257 | { | 257 | { |
258 | static DEFINE_MUTEX(spi_add_lock); | 258 | static DEFINE_MUTEX(spi_add_lock); |
259 | struct device *dev = spi->master->dev.parent; | 259 | struct device *dev = spi->master->dev.parent; |
260 | struct device *d; | ||
260 | int status; | 261 | int status; |
261 | 262 | ||
262 | /* Chipselects are numbered 0..max; validate. */ | 263 | /* Chipselects are numbered 0..max; validate. */ |
@@ -278,10 +279,11 @@ int spi_add_device(struct spi_device *spi) | |||
278 | */ | 279 | */ |
279 | mutex_lock(&spi_add_lock); | 280 | mutex_lock(&spi_add_lock); |
280 | 281 | ||
281 | if (bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev)) | 282 | d = bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev)); |
282 | != NULL) { | 283 | if (d != NULL) { |
283 | dev_err(dev, "chipselect %d already in use\n", | 284 | dev_err(dev, "chipselect %d already in use\n", |
284 | spi->chip_select); | 285 | spi->chip_select); |
286 | put_device(d); | ||
285 | status = -EBUSY; | 287 | status = -EBUSY; |
286 | goto done; | 288 | goto done; |
287 | } | 289 | } |