summaryrefslogtreecommitdiff
path: root/drivers/base/dd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/dd.c')
-rw-r--r--drivers/base/dd.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index ce30f34e7944..86e230973010 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -506,6 +506,19 @@ static ssize_t state_synced_show(struct device *dev,
}
static DEVICE_ATTR_RO(state_synced);
+static void device_unbind_cleanup(struct device *dev)
+{
+ devres_release_all(dev);
+ arch_teardown_dma_ops(dev);
+ kfree(dev->dma_range_map);
+ dev->dma_range_map = NULL;
+ dev->driver = NULL;
+ dev_set_drvdata(dev, NULL);
+ if (dev->pm_domain && dev->pm_domain->dismiss)
+ dev->pm_domain->dismiss(dev);
+ pm_runtime_reinit(dev);
+ dev_pm_set_driver_flags(dev, 0);
+}
static int call_driver_probe(struct device *dev, struct device_driver *drv)
{
@@ -628,16 +641,8 @@ re_probe:
else if (drv->remove)
drv->remove(dev);
- devres_release_all(dev);
- arch_teardown_dma_ops(dev);
- kfree(dev->dma_range_map);
- dev->dma_range_map = NULL;
driver_sysfs_remove(dev);
- dev->driver = NULL;
- dev_set_drvdata(dev, NULL);
- if (dev->pm_domain && dev->pm_domain->dismiss)
- dev->pm_domain->dismiss(dev);
- pm_runtime_reinit(dev);
+ device_unbind_cleanup(dev);
goto re_probe;
}
@@ -667,16 +672,7 @@ sysfs_failed:
BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
pinctrl_bind_failed:
device_links_no_driver(dev);
- devres_release_all(dev);
- arch_teardown_dma_ops(dev);
- kfree(dev->dma_range_map);
- dev->dma_range_map = NULL;
- dev->driver = NULL;
- dev_set_drvdata(dev, NULL);
- if (dev->pm_domain && dev->pm_domain->dismiss)
- dev->pm_domain->dismiss(dev);
- pm_runtime_reinit(dev);
- dev_pm_set_driver_flags(dev, 0);
+ device_unbind_cleanup(dev);
done:
return ret;
}
@@ -1209,17 +1205,7 @@ static void __device_release_driver(struct device *dev, struct device *parent)
drv->remove(dev);
device_links_driver_cleanup(dev);
-
- devres_release_all(dev);
- arch_teardown_dma_ops(dev);
- kfree(dev->dma_range_map);
- dev->dma_range_map = NULL;
- dev->driver = NULL;
- dev_set_drvdata(dev, NULL);
- if (dev->pm_domain && dev->pm_domain->dismiss)
- dev->pm_domain->dismiss(dev);
- pm_runtime_reinit(dev);
- dev_pm_set_driver_flags(dev, 0);
+ device_unbind_cleanup(dev);
klist_remove(&dev->p->knode_driver);
device_pm_check_callbacks(dev);