diff mbox series

libpdbg: Add api to get 32-bit device tree property

Message ID 20181023033528.31256-3-alistair@popple.id.au
State Superseded
Headers show
Series libpdbg: Add api to get 32-bit device tree property | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/build-multiarch fail Test build-multiarch on branch master

Commit Message

Alistair Popple Oct. 23, 2018, 3:35 a.m. UTC
---
 libpdbg/libpdbg.c | 12 ++++++++++++
 libpdbg/libpdbg.h |  1 +
 2 files changed, 13 insertions(+)

Comments

Amitay Isaacs Nov. 5, 2018, 1:02 a.m. UTC | #1
On Tue, 2018-10-23 at 14:35 +1100, Alistair Popple wrote:
> ---
>  libpdbg/libpdbg.c | 12 ++++++++++++
>  libpdbg/libpdbg.h |  1 +
>  2 files changed, 13 insertions(+)
> 
> diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
> index 810e045..ccaad3e 100644
> --- a/libpdbg/libpdbg.c
> +++ b/libpdbg/libpdbg.c
> @@ -186,6 +186,18 @@ static int pdbg_get_target_u64_property(struct
> pdbg_target *target, const char *
>  	return 0;
>  }
>  
> +int pdbg_get_target_u32_property(struct pdbg_target *target, const
> char *name, uint32_t *val)
> +{
> +	struct dt_property *p;
> +
> +	p = dt_find_property(target, name);
> +	if (!p)
> +		return -1;
> +
> +	*val = dt_get_number(p->prop, 1);
> +	return 0;
> +}
> +
>  int pdbg_get_u64_property(struct pdbg_target *target, const char
> *name, uint64_t *val)
>  {
>  	struct pdbg_target *dn;

May be we should add consistent function names?

How about pdbg_target_get_u32_property?
Or pdbg_target_get_property_u32?

We should fix names for get_property and set_property api too.
How much tied are we to the current libpdbg api?

> diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
> index c54e852..b1d6655 100644
> --- a/libpdbg/libpdbg.h
> +++ b/libpdbg/libpdbg.h
> @@ -72,6 +72,7 @@ void pdbg_set_target_property(struct pdbg_target
> *target, const char *name, cons
>  
>  /* Get the given property and return the size */
>  void *pdbg_get_target_property(struct pdbg_target *target, const
> char *name, size_t *size);
> +int pdbg_get_target_u32_property(struct pdbg_target *target, const
> char *name, uint32_t *val);
>  int pdbg_get_u64_property(struct pdbg_target *target, const char
> *name, uint64_t *val);
>  uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t
> *size);
>  
> -- 
> 2.11.0
> 

Amitay.
Alistair Popple Nov. 7, 2018, 4:49 a.m. UTC | #2
On Monday, 5 November 2018 12:02:58 PM AEDT Amitay Isaacs wrote:
> On Tue, 2018-10-23 at 14:35 +1100, Alistair Popple wrote:
> > ---
> > 
> >  libpdbg/libpdbg.c | 12 ++++++++++++
> >  libpdbg/libpdbg.h |  1 +
> >  2 files changed, 13 insertions(+)
> > 
> > diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
> > index 810e045..ccaad3e 100644
> > --- a/libpdbg/libpdbg.c
> > +++ b/libpdbg/libpdbg.c
> > @@ -186,6 +186,18 @@ static int pdbg_get_target_u64_property(struct
> > pdbg_target *target, const char *
> > 
> >  	return 0;
> >  
> >  }
> > 
> > +int pdbg_get_target_u32_property(struct pdbg_target *target, const
> > char *name, uint32_t *val)
> > +{
> > +	struct dt_property *p;
> > +
> > +	p = dt_find_property(target, name);
> > +	if (!p)
> > +		return -1;
> > +
> > +	*val = dt_get_number(p->prop, 1);
> > +	return 0;
> > +}
> > +
> > 
> >  int pdbg_get_u64_property(struct pdbg_target *target, const char
> > 
> > *name, uint64_t *val)
> > 
> >  {
> >  
> >  	struct pdbg_target *dn;
> 
> May be we should add consistent function names?

Agreed ...

> How about pdbg_target_get_u32_property?
> Or pdbg_target_get_property_u32?

... to the point where I caught this and changed it to 
pdbg_target_u32_property() in "[PATCH 04/10] libpdbg: Rename property 
functions" ...

> We should fix names for get_property and set_property api too.

... which also changes those.

> How much tied are we to the current libpdbg api?

Somewhat but not strictly. We have two other projects that I know of using the 
API and they're both fairly easy to update.

- Alistair

> > diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
> > index c54e852..b1d6655 100644
> > --- a/libpdbg/libpdbg.h
> > +++ b/libpdbg/libpdbg.h
> > @@ -72,6 +72,7 @@ void pdbg_set_target_property(struct pdbg_target
> > *target, const char *name, cons
> > 
> >  /* Get the given property and return the size */
> >  void *pdbg_get_target_property(struct pdbg_target *target, const
> > 
> > char *name, size_t *size);
> > +int pdbg_get_target_u32_property(struct pdbg_target *target, const
> > char *name, uint32_t *val);
> > 
> >  int pdbg_get_u64_property(struct pdbg_target *target, const char
> > 
> > *name, uint64_t *val);
> > 
> >  uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t
> > 
> > *size);
> 
> Amitay.
diff mbox series

Patch

diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
index 810e045..ccaad3e 100644
--- a/libpdbg/libpdbg.c
+++ b/libpdbg/libpdbg.c
@@ -186,6 +186,18 @@  static int pdbg_get_target_u64_property(struct pdbg_target *target, const char *
 	return 0;
 }
 
+int pdbg_get_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val)
+{
+	struct dt_property *p;
+
+	p = dt_find_property(target, name);
+	if (!p)
+		return -1;
+
+	*val = dt_get_number(p->prop, 1);
+	return 0;
+}
+
 int pdbg_get_u64_property(struct pdbg_target *target, const char *name, uint64_t *val)
 {
 	struct pdbg_target *dn;
diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index c54e852..b1d6655 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -72,6 +72,7 @@  void pdbg_set_target_property(struct pdbg_target *target, const char *name, cons
 
 /* Get the given property and return the size */
 void *pdbg_get_target_property(struct pdbg_target *target, const char *name, size_t *size);
+int pdbg_get_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val);
 int pdbg_get_u64_property(struct pdbg_target *target, const char *name, uint64_t *val);
 uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t *size);