Commit b8b2c7d8 authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Greg Kroah-Hartman

base/platform: assert that dev_pm_domain callbacks are called unconditionally

When a platform driver doesn't provide a .remove callback the function
platform_drv_remove isn't called and so the call to dev_pm_domain_attach
called at probe time isn't paired by dev_pm_domain_detach at remove
time.

To fix this (and similar issues if different callbacks are missing) hook
up the driver callbacks unconditionally and make them aware that the
platform callbacks might be missing.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 65da3484
...@@ -513,7 +513,7 @@ static int platform_drv_probe(struct device *_dev) ...@@ -513,7 +513,7 @@ static int platform_drv_probe(struct device *_dev)
return ret; return ret;
ret = dev_pm_domain_attach(_dev, true); ret = dev_pm_domain_attach(_dev, true);
if (ret != -EPROBE_DEFER) { if (ret != -EPROBE_DEFER && drv->probe) {
ret = drv->probe(dev); ret = drv->probe(dev);
if (ret) if (ret)
dev_pm_domain_detach(_dev, true); dev_pm_domain_detach(_dev, true);
...@@ -536,8 +536,9 @@ static int platform_drv_remove(struct device *_dev) ...@@ -536,8 +536,9 @@ static int platform_drv_remove(struct device *_dev)
{ {
struct platform_driver *drv = to_platform_driver(_dev->driver); struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev); struct platform_device *dev = to_platform_device(_dev);
int ret; int ret = 0;
if (drv->remove)
ret = drv->remove(dev); ret = drv->remove(dev);
dev_pm_domain_detach(_dev, true); dev_pm_domain_detach(_dev, true);
...@@ -549,6 +550,7 @@ static void platform_drv_shutdown(struct device *_dev) ...@@ -549,6 +550,7 @@ static void platform_drv_shutdown(struct device *_dev)
struct platform_driver *drv = to_platform_driver(_dev->driver); struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev); struct platform_device *dev = to_platform_device(_dev);
if (drv->shutdown)
drv->shutdown(dev); drv->shutdown(dev);
dev_pm_domain_detach(_dev, true); dev_pm_domain_detach(_dev, true);
} }
...@@ -563,11 +565,8 @@ int __platform_driver_register(struct platform_driver *drv, ...@@ -563,11 +565,8 @@ int __platform_driver_register(struct platform_driver *drv,
{ {
drv->driver.owner = owner; drv->driver.owner = owner;
drv->driver.bus = &platform_bus_type; drv->driver.bus = &platform_bus_type;
if (drv->probe)
drv->driver.probe = platform_drv_probe; drv->driver.probe = platform_drv_probe;
if (drv->remove)
drv->driver.remove = platform_drv_remove; drv->driver.remove = platform_drv_remove;
if (drv->shutdown)
drv->driver.shutdown = platform_drv_shutdown; drv->driver.shutdown = platform_drv_shutdown;
return driver_register(&drv->driver); return driver_register(&drv->driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment