Message ID | 20191003041909.23187-11-amitay@ozlabs.org |
---|---|
State | Accepted |
Headers | show |
Series | Add system device tree to libpdbg | expand |
Reviewed-by: Alistair Popple <alistair@popple.id.au> On Thursday, 3 October 2019 2:18:49 PM AEDT Amitay Isaacs wrote: > 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@ozlabs.org> > --- > libpdbg/device.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/libpdbg/device.c b/libpdbg/device.c > index 6e2e7bb..2a02504 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); > } > > static struct dt_property *dt_find_property(const struct pdbg_target *node, >
diff --git a/libpdbg/device.c b/libpdbg/device.c index 6e2e7bb..2a02504 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); } static struct dt_property *dt_find_property(const struct pdbg_target *node,
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@ozlabs.org> --- libpdbg/device.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)