diff mbox series

[v5,22/30] libpdbg: Pass root node to dt_expand

Message ID 20191014051748.20190-23-amitay@ozlabs.org
State Accepted
Headers show
Series Add system device tree to libpdbg | expand

Commit Message

Amitay Isaacs Oct. 14, 2019, 5:17 a.m. UTC
This will enable parsing more than one device tree.

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

Patch

diff --git a/libpdbg/device.c b/libpdbg/device.c
index f357e99..ef09019 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -604,7 +604,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);
 
@@ -749,9 +749,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();
 
@@ -760,7 +757,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);
 }