diff mbox series

[v3,14/22] libpdbg: Pass root node to dt_expand

Message ID 20190923084841.18057-15-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 (da6691975ea6a06d79cfd2ba9a7a1af39f839a41)
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Amitay Isaacs Sept. 23, 2019, 8:48 a.m. UTC
This will enable parsing more than one device tree.

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

Comments

Alistair Popple Sept. 26, 2019, 5:29 a.m. UTC | #1
Reviewed-by: Alistair Popple <alistair@popple.id.au>

On Monday, 23 September 2019 6:48:33 PM AEST Amitay Isaacs wrote:
> This will enable parsing more than one device tree.
> 
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  libpdbg/device.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libpdbg/device.c b/libpdbg/device.c
> index 960d23a..7926040 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);
>  
> @@ -742,9 +742,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();
>  
> @@ -753,7 +750,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);
>  }
>  
>
diff mbox series

Patch

diff --git a/libpdbg/device.c b/libpdbg/device.c
index 960d23a..7926040 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);
 
@@ -742,9 +742,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();
 
@@ -753,7 +750,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);
 }