summaryrefslogtreecommitdiff
path: root/drivers/base/dd.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-12-04 23:49:17 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-12-09 01:25:01 +0100
commit14b6257a5f3dca3817b0826cb32967e3c2b935c8 (patch)
treecaf824c65fb41b7678056fda79a40c180001b87c /drivers/base/dd.c
parent4077a387b79f41e262e9e7332a23b24860407b18 (diff)
device core: add BUS_NOTIFY_DRIVER_NOT_BOUND notification
The users of BUS_NOTIFY_BIND_DRIVER have no chance to do any cleanup in case of a probe failure. In the result there might be problems, such as some resources that had been allocated will continue to be allocated and therefore lead to a resource leak. Introduce a new notification to inform the subscriber that ->probe() failed. Do the same in case of failed device_bind_driver() call. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/dd.c')
-rw-r--r--drivers/base/dd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a641cf3ccad6..03697043344a 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -268,6 +268,9 @@ int device_bind_driver(struct device *dev)
ret = driver_sysfs_add(dev);
if (!ret)
driver_bound(dev);
+ else if (dev->bus)
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
+ BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
return ret;
}
EXPORT_SYMBOL_GPL(device_bind_driver);
@@ -290,7 +293,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
/* If using pinctrl, bind pins now before probing */
ret = pinctrl_bind_pins(dev);
if (ret)
- goto probe_failed;
+ goto pinctrl_bind_failed;
if (driver_sysfs_add(dev)) {
printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
@@ -334,6 +337,10 @@ static int really_probe(struct device *dev, struct device_driver *drv)
goto done;
probe_failed:
+ if (dev->bus)
+ blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
+ BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
+pinctrl_bind_failed:
devres_release_all(dev);
driver_sysfs_remove(dev);
dev->driver = NULL;
@@ -701,7 +708,6 @@ static void __device_release_driver(struct device *dev)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
BUS_NOTIFY_UNBOUND_DRIVER,
dev);
-
}
}