From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] dm: core: Add dm_remove_devices_flags() and hook it into device_remove()
Date: Fri, 10 Mar 2017 14:50:05 +0100 [thread overview]
Message-ID: <20170310135006.14673-2-sr@denx.de> (raw)
In-Reply-To: <20170310135006.14673-1-sr@denx.de>
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>
Cc: Simon Glass <sjg@chromium.org>
---
drivers/core/device-remove.c | 15 +++++++++++----
drivers/core/root.c | 7 +++++++
include/dm/root.h | 12 ++++++++++++
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index b80bf52320..ca4680f7c2 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -174,7 +174,12 @@ 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 the driver flags
+ */
+ if (drv->remove &&
+ ((flags & DM_REMOVE_NORMAL) || (flags & drv->flags))) {
ret = drv->remove(dev);
if (ret)
goto err_remove;
@@ -188,10 +193,12 @@ int device_remove(struct udevice *dev, uint flags)
}
}
- device_free(dev);
+ if ((flags & DM_REMOVE_NORMAL) || (flags & drv->flags)) {
+ 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 6dafc6ecfc..4c4642a8a4 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -182,6 +182,13 @@ int dm_uninit(void)
return 0;
}
+int dm_remove_devices_flags(uint flags)
+{
+ device_remove(dm_root(), flags);
+
+ return 0;
+}
+
int dm_scan_platdata(bool pre_reloc_only)
{
int ret;
diff --git a/include/dm/root.h b/include/dm/root.h
index 3cf730dcee..b13c005c17 100644
--- a/include/dm/root.h
+++ b/include/dm/root.h
@@ -115,4 +115,16 @@ int dm_init(void);
*/
int dm_uninit(void);
+/**
+ * dm_remove_devices_flags - Call remove function of all drivers with
+ * specific removal flags set to selectively
+ * remove drivers
+ *
+ * All devices with the matching flags set will be removed
+ *
+ * @flags: Flags for selective device removal
+ * @return 0 if OK, -ve on error
+ */
+int dm_remove_devices_flags(uint flags);
+
#endif
--
2.12.0
next prev parent reply other threads:[~2017-03-10 13:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 13:50 [U-Boot] [PATCH 1/3] dm: core: Add flags parameter to device_remove() Stefan Roese
2017-03-10 13:50 ` Stefan Roese [this message]
2017-03-13 12:33 ` [U-Boot] [PATCH 2/3] dm: core: Add dm_remove_devices_flags() and hook it into device_remove() Simon Glass
2017-03-10 13:50 ` [U-Boot] [PATCH 3/3] arm: bootm: Add dm_remove_devices_flags() call to announce_and_cleanup() Stefan Roese
2017-03-13 12:34 ` Simon Glass
2017-03-13 12:50 ` Stefan Roese
2017-03-13 13:20 ` Stefan Roese
2017-03-13 13:23 ` Simon Glass
2017-03-13 12:33 ` [U-Boot] [PATCH 1/3] dm: core: Add flags parameter to device_remove() Simon Glass
2017-03-13 12:43 ` Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170310135006.14673-2-sr@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox