diff mbox series

[01/13] libpdbg: Cache device tree pointer and offset for each node

Message ID 20200115051901.17514-2-amitay@ozlabs.org
State Accepted
Headers show
Series Use fdt properties directly | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch master (8b4611b5d8e7e2279fe4aa80c892fcfe10aa398d)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Amitay Isaacs Jan. 15, 2020, 5:18 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/device.c | 9 ++++++---
 libpdbg/target.h | 2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

Alistair Popple Jan. 16, 2020, 1:23 a.m. UTC | #1
Global variables for the win? ;-)

Reviewed-by: Alistair Popple <alistair@popple.id.au>

On Wednesday, 15 January 2020 4:18:49 PM AEDT Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> ---
>  libpdbg/device.c | 9 ++++++---
>  libpdbg/target.h | 2 ++
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/libpdbg/device.c b/libpdbg/device.c
> index ad498dc..ac2351d 100644
> --- a/libpdbg/device.c
> +++ b/libpdbg/device.c
> @@ -115,7 +115,7 @@ static struct pdbg_target *dt_pdbg_target_new(const void
> *fdt, int node_offset) return target;
>  }
> 
> -static struct pdbg_target *dt_new_node(const char *name, const void *fdt,
> int node_offset) +static struct pdbg_target *dt_new_node(const char *name,
> void *fdt, int node_offset) {
>  	struct pdbg_target *node = NULL;
>  	size_t size = sizeof(*node);
> @@ -131,6 +131,9 @@ static struct pdbg_target *dt_new_node(const char *name,
> const void *fdt, int no abort();
>  	}
> 
> +	node->fdt = fdt;
> +	node->fdt_offset = fdt ? node_offset : -1;
> +
>  	node->dn_name = take_name(name);
>  	node->parent = NULL;
>  	list_head_init(&node->properties);
> @@ -547,7 +550,7 @@ static enum pdbg_target_status str_to_status(const char
> *status) assert(0);
>  }
> 
> -static int dt_expand_node(struct pdbg_target *node, const void *fdt, int
> fdt_node) +static int dt_expand_node(struct pdbg_target *node, void *fdt,
> int fdt_node) {
>  	const struct fdt_property *prop;
>  	int offset, nextoffset, err;
> @@ -604,7 +607,7 @@ static int dt_expand_node(struct pdbg_target *node,
> const void *fdt, int fdt_nod return nextoffset;
>  }
> 
> -static void dt_expand(struct pdbg_target *root, const void *fdt)
> +static void dt_expand(struct pdbg_target *root, void *fdt)
>  {
>  	PR_DEBUG("FDT: Parsing fdt @%p\n", fdt);
> 
> diff --git a/libpdbg/target.h b/libpdbg/target.h
> index a8f777d..9e25a43 100644
> --- a/libpdbg/target.h
> +++ b/libpdbg/target.h
> @@ -39,6 +39,8 @@ struct pdbg_target {
>  	int (*probe)(struct pdbg_target *target);
>  	void (*release)(struct pdbg_target *target);
>  	uint64_t (*translate)(struct pdbg_target *target, uint64_t addr);
> +	void *fdt;
> +	int fdt_offset;
>  	int index;
>  	enum pdbg_target_status status;
>  	const char *dn_name;
Amitay Isaacs Jan. 16, 2020, 2:33 a.m. UTC | #2
On Thu, 2020-01-16 at 12:23 +1100, Alistair Popple wrote:
> Global variables for the win? ;-)

Well, we don't have a context to hang things off.  So global variables
will have to do!


> 
> Reviewed-by: Alistair Popple <alistair@popple.id.au>
> 
> On Wednesday, 15 January 2020 4:18:49 PM AEDT Amitay Isaacs wrote:
> > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
> > ---
> >  libpdbg/device.c | 9 ++++++---
> >  libpdbg/target.h | 2 ++
> >  2 files changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libpdbg/device.c b/libpdbg/device.c
> > index ad498dc..ac2351d 100644
> > --- a/libpdbg/device.c
> > +++ b/libpdbg/device.c
> > @@ -115,7 +115,7 @@ static struct pdbg_target
> > *dt_pdbg_target_new(const void
> > *fdt, int node_offset) return target;
> >  }
> > 
> > -static struct pdbg_target *dt_new_node(const char *name, const
> > void *fdt,
> > int node_offset) +static struct pdbg_target *dt_new_node(const char
> > *name,
> > void *fdt, int node_offset) {
> >  	struct pdbg_target *node = NULL;
> >  	size_t size = sizeof(*node);
> > @@ -131,6 +131,9 @@ static struct pdbg_target *dt_new_node(const
> > char *name,
> > const void *fdt, int no abort();
> >  	}
> > 
> > +	node->fdt = fdt;
> > +	node->fdt_offset = fdt ? node_offset : -1;
> > +
> >  	node->dn_name = take_name(name);
> >  	node->parent = NULL;
> >  	list_head_init(&node->properties);
> > @@ -547,7 +550,7 @@ static enum pdbg_target_status
> > str_to_status(const char
> > *status) assert(0);
> >  }
> > 
> > -static int dt_expand_node(struct pdbg_target *node, const void
> > *fdt, int
> > fdt_node) +static int dt_expand_node(struct pdbg_target *node, void
> > *fdt,
> > int fdt_node) {
> >  	const struct fdt_property *prop;
> >  	int offset, nextoffset, err;
> > @@ -604,7 +607,7 @@ static int dt_expand_node(struct pdbg_target
> > *node,
> > const void *fdt, int fdt_nod return nextoffset;
> >  }
> > 
> > -static void dt_expand(struct pdbg_target *root, const void *fdt)
> > +static void dt_expand(struct pdbg_target *root, void *fdt)
> >  {
> >  	PR_DEBUG("FDT: Parsing fdt @%p\n", fdt);
> > 
> > diff --git a/libpdbg/target.h b/libpdbg/target.h
> > index a8f777d..9e25a43 100644
> > --- a/libpdbg/target.h
> > +++ b/libpdbg/target.h
> > @@ -39,6 +39,8 @@ struct pdbg_target {
> >  	int (*probe)(struct pdbg_target *target);
> >  	void (*release)(struct pdbg_target *target);
> >  	uint64_t (*translate)(struct pdbg_target *target, uint64_t
> > addr);
> > +	void *fdt;
> > +	int fdt_offset;
> >  	int index;
> >  	enum pdbg_target_status status;
> >  	const char *dn_name;
> 
> 
> 

Amitay.
diff mbox series

Patch

diff --git a/libpdbg/device.c b/libpdbg/device.c
index ad498dc..ac2351d 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -115,7 +115,7 @@  static struct pdbg_target *dt_pdbg_target_new(const void *fdt, int node_offset)
 	return target;
 }
 
-static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int node_offset)
+static struct pdbg_target *dt_new_node(const char *name, void *fdt, int node_offset)
 {
 	struct pdbg_target *node = NULL;
 	size_t size = sizeof(*node);
@@ -131,6 +131,9 @@  static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int no
 		abort();
 	}
 
+	node->fdt = fdt;
+	node->fdt_offset = fdt ? node_offset : -1;
+
 	node->dn_name = take_name(name);
 	node->parent = NULL;
 	list_head_init(&node->properties);
@@ -547,7 +550,7 @@  static enum pdbg_target_status str_to_status(const char *status)
 		assert(0);
 }
 
-static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_node)
+static int dt_expand_node(struct pdbg_target *node, void *fdt, int fdt_node)
 {
 	const struct fdt_property *prop;
 	int offset, nextoffset, err;
@@ -604,7 +607,7 @@  static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod
 	return nextoffset;
 }
 
-static void dt_expand(struct pdbg_target *root, const void *fdt)
+static void dt_expand(struct pdbg_target *root, void *fdt)
 {
 	PR_DEBUG("FDT: Parsing fdt @%p\n", fdt);
 
diff --git a/libpdbg/target.h b/libpdbg/target.h
index a8f777d..9e25a43 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -39,6 +39,8 @@  struct pdbg_target {
 	int (*probe)(struct pdbg_target *target);
 	void (*release)(struct pdbg_target *target);
 	uint64_t (*translate)(struct pdbg_target *target, uint64_t addr);
+	void *fdt;
+	int fdt_offset;
 	int index;
 	enum pdbg_target_status status;
 	const char *dn_name;