[Pdbg] [PATCH 09/23] libpdbg: Parent retrieval should skip over virtual nodes
Amitay Isaacs
amitay at ozlabs.org
Thu Sep 19 12:33:19 AEST 2019
Internally, parent of a device tree node should return the parent as per
the backend device tree and not system device tree view.
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/libpdbg.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
index b17853d..ae7a823 100644
--- a/libpdbg/libpdbg.c
+++ b/libpdbg/libpdbg.c
@@ -6,6 +6,20 @@
static pdbg_progress_tick_t progress_tick;
+static struct pdbg_target *get_parent(struct pdbg_target *target)
+{
+ struct pdbg_target *parent;
+
+ parent = target->parent;
+ if (!parent || !parent->vnode)
+ return parent;
+
+ if (parent->compatible)
+ return parent;
+
+ return parent->vnode;
+}
+
struct pdbg_target *__pdbg_next_target(const char *class, struct pdbg_target *parent, struct pdbg_target *last)
{
struct pdbg_target *next, *tmp;
@@ -33,7 +47,7 @@ retry:
return next;
else {
/* Check if this target is a child of the given parent */
- for (tmp = next; tmp && next->parent && tmp != parent; tmp = tmp->parent) {}
+ for (tmp = next; tmp && get_parent(tmp) && tmp != parent; tmp = get_parent(tmp)) {}
if (tmp == parent)
return next;
else {
@@ -116,7 +130,7 @@ uint32_t pdbg_target_index(struct pdbg_target *target)
{
struct pdbg_target *dn;
- for (dn = target; dn && dn->index == -1; dn = dn->parent);
+ for (dn = target; dn && dn->index == -1; dn = get_parent(dn));
if (!dn)
return -1;
@@ -130,9 +144,9 @@ struct pdbg_target *pdbg_target_parent(const char *class, struct pdbg_target *ta
struct pdbg_target *parent;
if (!class)
- return target->parent;
+ return get_parent(target);
- for (parent = target->parent; parent && parent->parent; parent = parent->parent) {
+ for (parent = get_parent(target); parent && get_parent(parent); parent = get_parent(parent)) {
if (!strcmp(class, pdbg_target_class_name(parent)))
return parent;
}
--
2.21.0
More information about the Pdbg
mailing list