diff mbox series

libpdbg: Add API to get device tree path and find target via path

Message ID 20181023033528.31256-6-alistair@popple.id.au
State Superseded
Headers show
Series libpdbg: Add API to get device tree path and find target via path | 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
Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 libpdbg/libpdbg.c | 13 +++++++++++++
 libpdbg/libpdbg.h |  2 ++
 2 files changed, 15 insertions(+)

Comments

Amitay Isaacs Nov. 5, 2018, 1:21 a.m. UTC | #1
On Tue, 2018-10-23 at 14:35 +1100, Alistair Popple wrote:
> Signed-off-by: Alistair Popple <alistair@popple.id.au>
> ---
>  libpdbg/libpdbg.c | 13 +++++++++++++
>  libpdbg/libpdbg.h |  2 ++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
> index ccaad3e..106cb58 100644
> --- a/libpdbg/libpdbg.c
> +++ b/libpdbg/libpdbg.c
> @@ -135,6 +135,19 @@ const char *pdbg_target_dn_name(struct
> pdbg_target *target)
>  	return target->dn_name;
>  }
>  
> +char *pdbg_target_path(const struct pdbg_target *target)
> +{
> +	return dt_get_path(target);
> +}

This is better api than my attempt to add path_target_path(). :-)

> +
> +struct pdbg_target *pdbg_target_find_by_path(struct pdbg_target
> *target, const char *path)
> +{
> +	if (!target)
> +		target = dt_root;
> +
> +	return dt_find_by_path(target, path);
> +}
> +

How about pdbg_target_from_path() instead?

>  void pdbg_set_target_property(struct pdbg_target *target, const char
> *name, const void *val, size_t size)
>  {
>  	struct dt_property *p;
> diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
> index ce11fff..fded62c 100644
> --- a/libpdbg/libpdbg.h
> +++ b/libpdbg/libpdbg.h
> @@ -84,6 +84,8 @@ void pdbg_target_release(struct pdbg_target
> *target);
>  enum pdbg_target_status pdbg_target_status(struct pdbg_target
> *target);
>  void pdbg_target_status_set(struct pdbg_target *target, enum
> pdbg_target_status status);
>  uint32_t pdbg_target_index(struct pdbg_target *target);
> +char *pdbg_target_path(const struct pdbg_target *target);
> +struct pdbg_target *pdbg_target_find_by_path(struct pdbg_target
> *target, const char *path);
>  uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass);
>  char *pdbg_target_class_name(struct pdbg_target *target);
>  char *pdbg_target_name(struct pdbg_target *target);
> -- 
> 2.11.0
> 

Amitay.
Alistair Popple Nov. 7, 2018, 4:55 a.m. UTC | #2
> > +char *pdbg_target_path(const struct pdbg_target *target)
> > +{
> > +	return dt_get_path(target);
> > +}
> 
> This is better api than my attempt to add path_target_path(). :-)

:-)
 
> > +
> > +struct pdbg_target *pdbg_target_find_by_path(struct pdbg_target
> > *target, const char *path)
> > +{
> > +	if (!target)
> > +		target = dt_root;
> > +
> > +	return dt_find_by_path(target, path);
> > +}
> > +
> 
> How about pdbg_target_from_path() instead?

I like less typing, good idea. Will change it.

- Alistair

> >  void pdbg_set_target_property(struct pdbg_target *target, const char
> > 
> > *name, const void *val, size_t size)
> > 
> >  {
> >  
> >  	struct dt_property *p;
> > 
> > diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
> > index ce11fff..fded62c 100644
> > --- a/libpdbg/libpdbg.h
> > +++ b/libpdbg/libpdbg.h
> > @@ -84,6 +84,8 @@ void pdbg_target_release(struct pdbg_target
> > *target);
> > 
> >  enum pdbg_target_status pdbg_target_status(struct pdbg_target
> > 
> > *target);
> > 
> >  void pdbg_target_status_set(struct pdbg_target *target, enum
> > 
> > pdbg_target_status status);
> > 
> >  uint32_t pdbg_target_index(struct pdbg_target *target);
> > 
> > +char *pdbg_target_path(const struct pdbg_target *target);
> > +struct pdbg_target *pdbg_target_find_by_path(struct pdbg_target
> > *target, const char *path);
> > 
> >  uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass);
> >  char *pdbg_target_class_name(struct pdbg_target *target);
> >  char *pdbg_target_name(struct pdbg_target *target);
> 
> Amitay.
Amitay Isaacs Nov. 7, 2018, 5:01 a.m. UTC | #3
On Wed, 2018-11-07 at 15:55 +1100, Alistair Popple wrote:
> > > +char *pdbg_target_path(const struct pdbg_target *target)
> > > +{
> > > +	return dt_get_path(target);
> > > +}
> > 
> > This is better api than my attempt to add path_target_path(). :-)
> 
> :-)
>  

I have now dropped that code from my patches.  I need some version of
this patch before I can post path based targeting patches.

Amitay.
diff mbox series

Patch

diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
index ccaad3e..106cb58 100644
--- a/libpdbg/libpdbg.c
+++ b/libpdbg/libpdbg.c
@@ -135,6 +135,19 @@  const char *pdbg_target_dn_name(struct pdbg_target *target)
 	return target->dn_name;
 }
 
+char *pdbg_target_path(const struct pdbg_target *target)
+{
+	return dt_get_path(target);
+}
+
+struct pdbg_target *pdbg_target_find_by_path(struct pdbg_target *target, const char *path)
+{
+	if (!target)
+		target = dt_root;
+
+	return dt_find_by_path(target, path);
+}
+
 void pdbg_set_target_property(struct pdbg_target *target, const char *name, const void *val, size_t size)
 {
 	struct dt_property *p;
diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index ce11fff..fded62c 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -84,6 +84,8 @@  void pdbg_target_release(struct pdbg_target *target);
 enum pdbg_target_status pdbg_target_status(struct pdbg_target *target);
 void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status status);
 uint32_t pdbg_target_index(struct pdbg_target *target);
+char *pdbg_target_path(const struct pdbg_target *target);
+struct pdbg_target *pdbg_target_find_by_path(struct pdbg_target *target, const char *path);
 uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass);
 char *pdbg_target_class_name(struct pdbg_target *target);
 char *pdbg_target_name(struct pdbg_target *target);