[Pdbg] [PATCH 03/14] libpdbg/target: add a release operation
Nicholas Piggin
npiggin at gmail.com
Mon Apr 9 17:35:11 AEST 2018
This will be used to release special wakeup.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
libpdbg/target.c | 29 +++++++++++++++++++++++++++++
libpdbg/target.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/libpdbg/target.c b/libpdbg/target.c
index 1eb85bb..950aee4 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -338,6 +338,27 @@ static void _target_probe(struct dt_node *dn)
}
}
+static void _target_release(struct dt_node *dn)
+{
+ struct dt_property *p;
+
+ PR_DEBUG("Release %s - ", dn->name);
+ if (!dn->target) {
+ PR_DEBUG("target not found\n");
+ return;
+ }
+
+ p = dt_find_property(dn, "status");
+ if (p && !strcmp(p->prop, "disabled")) {
+ PR_DEBUG("disabled\n");
+ return;
+ }
+
+ if (dn->target->release)
+ dn->target->release(dn->target);
+ PR_DEBUG("success\n");
+}
+
/* We walk the tree root down disabling targets which might/should
* exist but don't */
void pdbg_target_probe(void)
@@ -348,6 +369,14 @@ void pdbg_target_probe(void)
_target_probe(dn);
}
+void pdbg_target_release(void)
+{
+ struct dt_node *dn;
+
+ dt_for_each_node(dt_root, dn)
+ _target_release(dn);
+}
+
bool pdbg_target_is_class(struct pdbg_target *target, const char *class)
{
if (!target || !target->class || !class)
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 0a618e2..99a4d68 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -43,6 +43,7 @@ struct pdbg_target {
char *compatible;
char *class;
int (*probe)(struct pdbg_target *target);
+ void (*release)(struct pdbg_target *target);
int index;
struct dt_node *dn;
struct list_node class_link;
--
2.17.0
More information about the Pdbg
mailing list