[Pdbg] [PATCH 10/23] libpdbg: Use pdbg api to get parent

Amitay Isaacs amitay at ozlabs.org
Thu Sep 19 12:33:20 AEST 2019


This ensures that virtual nodes are handled correctly.

Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 libpdbg/cfam.c   |  2 +-
 libpdbg/target.c | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libpdbg/cfam.c b/libpdbg/cfam.c
index 868ca76..470b167 100644
--- a/libpdbg/cfam.c
+++ b/libpdbg/cfam.c
@@ -313,7 +313,7 @@ static int cfam_hmfsi_write(struct fsi *fsi, uint32_t addr, uint32_t data)
 static int cfam_hmfsi_probe(struct pdbg_target *target)
 {
 	struct fsi *fsi = target_to_fsi(target);
-	struct pdbg_target *fsi_parent = target->parent;
+	struct pdbg_target *fsi_parent = require_target_parent(target);
 	uint32_t value, port;
 	int rc;
 
diff --git a/libpdbg/target.c b/libpdbg/target.c
index 5808d02..d550be8 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -27,7 +27,7 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con
 			*addr += pdbg_target_address(target, NULL);
 
 		/* Keep walking the tree translating addresses */
-		target = target->parent;
+		target = pdbg_target_parent(NULL, target);
 
 		/* The root node doesn't have an address space so it's
 		 * an error in the device tree if we hit this. */
@@ -325,8 +325,11 @@ uint32_t sbe_ffdc_get(struct pdbg_target *target, const uint8_t **ffdc, uint32_t
 
 struct pdbg_target *require_target_parent(struct pdbg_target *target)
 {
-	assert(target->parent);
-	return target->parent;
+	struct pdbg_target *parent;
+
+	parent = pdbg_target_parent(NULL, target);
+	assert(parent);
+	return parent;
 }
 
 /* Finds the given class. Returns NULL if not found. */
@@ -391,7 +394,7 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target)
 		 * it's status won't have changed */
 		   return status;
 
-	parent = target->parent;
+	parent = pdbg_target_parent(NULL, target);
 	if (parent) {
 		/* Recurse up the tree to probe and set parent target status */
 		pdbg_target_probe(parent);
-- 
2.21.0



More information about the Pdbg mailing list