[Pdbg] [PATCH 15/23] libpdbg: Pass root node to dt_expand

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


This will enable parsing more than one device tree.

Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 libpdbg/device.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libpdbg/device.c b/libpdbg/device.c
index 4160ea8..b499171 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -602,7 +602,7 @@ static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod
 	return nextoffset;
 }
 
-static void dt_expand(void *root, const void *fdt)
+static void dt_expand(struct pdbg_target *root, const void *fdt)
 {
 	PR_DEBUG("FDT: Parsing fdt @%p\n", fdt);
 
@@ -720,9 +720,6 @@ skip:
 
 void pdbg_targets_init(void *fdt)
 {
-	/* Root node needs to be valid when this function returns */
-	pdbg_dt_root = dt_new_node("", NULL, 0);
-
 	if (!fdt)
 		fdt = pdbg_default_dtb();
 
@@ -731,7 +728,12 @@ void pdbg_targets_init(void *fdt)
 		return;
 	}
 
+	/* Root node needs to be valid when this function returns */
+	pdbg_dt_root = dt_new_node("", NULL, 0);
+	assert(pdbg_dt_root);
+
 	dt_expand(pdbg_dt_root, fdt);
+
 	pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root);
 }
 
-- 
2.21.0



More information about the Pdbg mailing list