Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ec130a0 authored by Roman Tereshonkov's avatar Roman Tereshonkov Committed by Grant Likely
Browse files

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: default avatarRoman Tereshonkov <roman.tereshonkov@nokia.com>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 9bd73715
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -257,6 +257,7 @@ int spi_add_device(struct spi_device *spi)
{
{
	static DEFINE_MUTEX(spi_add_lock);
	static DEFINE_MUTEX(spi_add_lock);
	struct device *dev = spi->master->dev.parent;
	struct device *dev = spi->master->dev.parent;
	struct device *d;
	int status;
	int status;


	/* Chipselects are numbered 0..max; validate. */
	/* Chipselects are numbered 0..max; validate. */
@@ -278,10 +279,11 @@ int spi_add_device(struct spi_device *spi)
	 */
	 */
	mutex_lock(&spi_add_lock);
	mutex_lock(&spi_add_lock);


	if (bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev))
	d = bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev));
			!= NULL) {
	if (d != NULL) {
		dev_err(dev, "chipselect %d already in use\n",
		dev_err(dev, "chipselect %d already in use\n",
				spi->chip_select);
				spi->chip_select);
		put_device(d);
		status = -EBUSY;
		status = -EBUSY;
		goto done;
		goto done;
	}
	}