summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2017-03-27 08:58:53 (GMT)
committerSimon Glass <sjg@chromium.org>2017-04-05 02:15:10 (GMT)
commitbc85aa4030ab9ccfc1349c320b085a8b792c602e (patch)
treeed90ce03c7f456e194b68c3bbe1edb902602584a /drivers/core
parent706865afe54eee83c1f3d7e9ea2f51db8e986d7b (diff)
downloadu-boot-fsl-qoriq-bc85aa4030ab9ccfc1349c320b085a8b792c602e.tar.xz
dm: core: Add dm_remove_devices_flags() and hook it into device_remove()
The new function dm_remove_devices_flags() is intented for driver specific last-stage cleanup operations before the OS is started. This patch adds this functionality and hooks it into the common device_remove() function. Drivers wanting to use this feature for some last-stage removal calls, need to add one of the DM_REMOVE_xx flags to their driver .flags. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device-remove.c17
-rw-r--r--drivers/core/root.c9
2 files changed, 22 insertions, 4 deletions
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index b80bf52..cc0043b 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -174,7 +174,13 @@ int device_remove(struct udevice *dev, uint flags)
if (ret)
goto err;
- if (drv->remove) {
+ /*
+ * Remove the device if called with the "normal" remove flag set,
+ * or if the remove flag matches any of the drivers remove flags
+ */
+ if (drv->remove &&
+ ((flags & DM_REMOVE_NORMAL) ||
+ (flags & (drv->flags & DM_FLAG_ACTIVE_DMA)))) {
ret = drv->remove(dev);
if (ret)
goto err_remove;
@@ -188,10 +194,13 @@ int device_remove(struct udevice *dev, uint flags)
}
}
- device_free(dev);
+ if ((flags & DM_REMOVE_NORMAL) ||
+ (flags & (drv->flags & DM_FLAG_ACTIVE_DMA))) {
+ device_free(dev);
- dev->seq = -1;
- dev->flags &= ~DM_FLAG_ACTIVATED;
+ dev->seq = -1;
+ dev->flags &= ~DM_FLAG_ACTIVATED;
+ }
return ret;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index d8c51fb..42679d0 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -184,6 +184,15 @@ int dm_uninit(void)
return 0;
}
+#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
+int dm_remove_devices_flags(uint flags)
+{
+ device_remove(dm_root(), flags);
+
+ return 0;
+}
+#endif
+
int dm_scan_platdata(bool pre_reloc_only)
{
int ret;