aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 9ffb0fdbd6fe..b3a1f9259b62 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -41,7 +41,7 @@ static void spidev_release(struct device *dev)
41 spi->master->cleanup(spi); 41 spi->master->cleanup(spi);
42 42
43 spi_master_put(spi->master); 43 spi_master_put(spi->master);
44 kfree(dev); 44 kfree(spi);
45} 45}
46 46
47static ssize_t 47static ssize_t
@@ -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 }