[Pdbg] [PATCH v5 10/30] libpdbg: Support paths including virtual nodes

Amitay Isaacs amitay at ozlabs.org
Mon Oct 14 16:17:28 AEDT 2019


With the presence of virtual nodes, some of the nodes can be reached
from the root using different paths:

  - using virtual nodes (which provide the system device tree view)
  - using the actual hwunits present in the backend (backend device tree)

Both device tree paths should result in the same target.

Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
Reviewed-by: Alistair Popple <alistair at popple.id.au>
---
 libpdbg/device.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libpdbg/device.c b/libpdbg/device.c
index 6e2e7bb..2776169 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -275,7 +275,7 @@ static struct pdbg_target *dt_find_by_path(struct pdbg_target *root, const char
 	struct pdbg_target *n;
 	const char *pn, *pa = NULL, *p = path, *nn = NULL, *na = NULL;
 	unsigned int pnl, pal, nnl, nal;
-	bool match;
+	bool match, vnode;
 
 	/* Walk path components */
 	while (*p) {
@@ -284,6 +284,9 @@ static struct pdbg_target *dt_find_by_path(struct pdbg_target *root, const char
 		if (pnl == 0 && pal == 0)
 			break;
 
+		vnode = false;
+
+again:
 		/* Compare with each child node */
 		match = false;
 		list_for_each(&root->children, n, list) {
@@ -300,10 +303,16 @@ static struct pdbg_target *dt_find_by_path(struct pdbg_target *root, const char
 		}
 
 		/* No child match */
-		if (!match)
+		if (!match) {
+			if (!vnode && root->vnode) {
+				vnode = true;
+				root = root->vnode;
+				goto again;
+			}
 			return NULL;
+		}
 	}
-	return root;
+	return target_to_real(root, false);
 }
 
 static struct dt_property *dt_find_property(const struct pdbg_target *node,
-- 
2.21.0



More information about the Pdbg mailing list