Message ID | 20181107053943.4307-2-alistair@popple.id.au |
---|---|
State | Superseded |
Headers | show |
Series | Cleanup old code | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | master/apply_patch Successfully applied |
snowpatch_ozlabs/build-multiarch | success | Test build-multiarch on branch master |
On Wed, 2018-11-07 at 16:39 +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; > +} > + Shouldn't this check if the property value is actually defined as u32? Currently it just gets the first 32 bits as stored in the fdt. > 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 1977c75..138521c 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.
On Wednesday, 7 November 2018 4:59:41 PM AEDT Amitay Isaacs wrote: > > +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; > > +} > > + > > Shouldn't this check if the property value is actually defined as u32? > Currently it just gets the first 32 bits as stored in the fdt. Yep. As you have pointed out though that gets fixed in a later patch, although I'd be lying if I said that was an intentional outcome of reworking the code :-) - Alistair > > 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 1977c75..138521c 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 --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 1977c75..138521c 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);