diff mbox series

libpdbg: Process all nodes for finding system-path attribute

Message ID 20200508042446.346553-1-amitay@ozlabs.org
State Accepted
Headers show
Series libpdbg: Process all nodes for finding system-path attribute | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (6c10b68bf774a9fe21affd5ef0b40084cd49800d)
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Amitay Isaacs May 8, 2020, 4:24 a.m. UTC
Even if a node is virtual and linked, it might have children that have
system-path attribute and they need to be processed.  So instead of
stopping the traverse for linked virtual targets, skip virtual targets
during processing.

Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/device.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libpdbg/device.c b/libpdbg/device.c
index 4d22da4..4665dce 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -661,6 +661,10 @@  static void pdbg_targets_init_virtual(struct pdbg_target *node, struct pdbg_targ
 	const char *system_path;
 	size_t len;
 
+	/* Skip virtual nodes */
+	if (target_is_virtual(node))
+		goto skip;
+
 	system_path = (const char *)pdbg_target_property(node, "system-path", &len);
 	if (!system_path)
 		goto skip;
@@ -679,21 +683,18 @@  static void pdbg_targets_init_virtual(struct pdbg_target *node, struct pdbg_targ
 	if (!vnode)
 		goto skip;
 
-	assert(target_is_virtual(vnode));
-
 	/*
-	 * If virtual node is not linked, then link with node;
-	 * otherwise skip
+	 * If the virtual node is linked, dt_find_by_path will return the
+	 * linked target.  So if we found a virtual target, then it's
+	 * definitely not linked.
 	 */
-	if (!vnode->vnode)
+	if (target_is_virtual(vnode)) {
+		assert(!vnode->vnode);
 		dt_link_virtual(node, vnode);
+	}
 
 skip:
 	list_for_each(&node->children, child, list) {
-		/* If a virtual node is already linked, skip */
-		if (target_is_virtual(child) && child->vnode)
-			continue;
-
 		pdbg_targets_init_virtual(child, root);
 	}
 }