diff mbox series

[v3,06/22] libpdbg: Construct unique path based on virtual nodes

Message ID 20190923084841.18057-7-amitay@ozlabs.org
State Superseded
Headers show
Series Add system device tree to libpdbg | expand

Checks

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

Commit Message

Amitay Isaacs Sept. 23, 2019, 8:48 a.m. UTC
Even though there can be two different paths to a node, libpdbg users
should always see the path as defined in system device tree (view) which
is the same and independent of the backend device tree.

Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
Reviewed-by: Alistair Popple <alistair@popple.id.au>
---
 libpdbg/device.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/libpdbg/device.c b/libpdbg/device.c
index cba4475..9cb2a0a 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -219,6 +219,9 @@  static char *dt_get_path(struct pdbg_target *node)
 		return strdup("<NULL>");
 
 	for (n = node; n; n = n->parent) {
+		if (n->vnode && n->compatible)
+			n = n->vnode;
+
 		len += strlen(n->dn_name);
 		if (n->parent || n == node)
 			len++;
@@ -227,6 +230,9 @@  static char *dt_get_path(struct pdbg_target *node)
 	assert(path);
 	p = path + len;
 	for (n = node; n; n = n->parent) {
+		if (n->vnode && n->compatible)
+			n = n->vnode;
+
 		len = strlen(n->dn_name);
 		p -= len;
 		memcpy(p, n->dn_name, len);