Message ID | 1415033196-30529-2-git-send-email-frediano.ziglio@huawei.com |
---|---|
State | New |
Headers | show |
Hi Frediano, On 11/03/2014 04:46 PM, Frediano Ziglio wrote: > From: Zoltan Kiss <zoltan.kiss@linaro.org> > > Signed-off-by: Zoltan Kiss <zoltan.kiss@huawei.com> You forgot to keep my reviewed-by from the last version. Regards, > --- > xen/common/device_tree.c | 13 ++++++++++--- > xen/include/xen/device_tree.h | 11 +++++++++++ > 2 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c > index f72b2e9..1a886c0 100644 > --- a/xen/common/device_tree.c > +++ b/xen/common/device_tree.c > @@ -160,14 +160,21 @@ const void *dt_get_property(const struct dt_device_node *np, > bool_t dt_property_read_u32(const struct dt_device_node *np, > const char *name, u32 *out_value) > { > - u32 len; > + return dt_property_read_u32_array(np, name, out_value, 1); > +} > + > +bool_t dt_property_read_u32_array(const struct dt_device_node *np, > + const char *name, u32 *out_value, u16 out_len) > +{ > + u32 len, i; > const __be32 *val; > > val = dt_get_property(np, name, &len); > - if ( !val || len < sizeof(*out_value) ) > + if ( !val || len < sizeof(*out_value) * out_len ) > return 0; > > - *out_value = be32_to_cpup(val); > + for ( i = 0; i < out_len; i++, val++ ) > + out_value[i] = be32_to_cpup(val); > > return 1; > } > diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h > index 08db8bc..629bfb2 100644 > --- a/xen/include/xen/device_tree.h > +++ b/xen/include/xen/device_tree.h > @@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const struct dt_device_node *np, > bool_t dt_property_read_u32(const struct dt_device_node *np, > const char *name, u32 *out_value); > /** > + * dt_property_read_u32_array - Helper to read a u32 array property. > + * @np: node to get the value > + * @name: name of the property > + * @out_value: pointer to return value > + * @out_len: length of the array > + * > + * Return true if get the desired value. > + */ > +bool_t dt_property_read_u32_array(const struct dt_device_node *np, > + const char *name, u32 *out_value, u16 out_len); > +/** > * dt_property_read_u64 - Helper to read a u64 property. > * @np: node to get the value > * @name: name of the property >
> > Hi Frediano, > > On 11/03/2014 04:46 PM, Frediano Ziglio wrote: > > From: Zoltan Kiss <zoltan.kiss@linaro.org> > > > > Signed-off-by: Zoltan Kiss <zoltan.kiss@huawei.com> > > You forgot to keep my reviewed-by from the last version. > > Regards, > You sent two mails, on first you add your reviewed-by but on the next one you put some comments so I though your reviewed-by was not valid anymore Frediano > > --- > > xen/common/device_tree.c | 13 ++++++++++--- > > xen/include/xen/device_tree.h | 11 +++++++++++ > > 2 files changed, 21 insertions(+), 3 deletions(-) > > > > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c > index > > f72b2e9..1a886c0 100644 > > --- a/xen/common/device_tree.c > > +++ b/xen/common/device_tree.c > > @@ -160,14 +160,21 @@ const void *dt_get_property(const struct > > dt_device_node *np, bool_t dt_property_read_u32(const struct > dt_device_node *np, > > const char *name, u32 *out_value) { > > - u32 len; > > + return dt_property_read_u32_array(np, name, out_value, 1); } > > + > > +bool_t dt_property_read_u32_array(const struct dt_device_node *np, > > + const char *name, u32 *out_value, > > +u16 out_len) { > > + u32 len, i; > > const __be32 *val; > > > > val = dt_get_property(np, name, &len); > > - if ( !val || len < sizeof(*out_value) ) > > + if ( !val || len < sizeof(*out_value) * out_len ) > > return 0; > > > > - *out_value = be32_to_cpup(val); > > + for ( i = 0; i < out_len; i++, val++ ) > > + out_value[i] = be32_to_cpup(val); > > > > return 1; > > } > > diff --git a/xen/include/xen/device_tree.h > > b/xen/include/xen/device_tree.h index 08db8bc..629bfb2 100644 > > --- a/xen/include/xen/device_tree.h > > +++ b/xen/include/xen/device_tree.h > > @@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const > > struct dt_device_node *np, bool_t dt_property_read_u32(const struct > dt_device_node *np, > > const char *name, u32 *out_value); > > /** > > + * dt_property_read_u32_array - Helper to read a u32 array property. > > + * @np: node to get the value > > + * @name: name of the property > > + * @out_value: pointer to return value > > + * @out_len: length of the array > > + * > > + * Return true if get the desired value. > > + */ > > +bool_t dt_property_read_u32_array(const struct dt_device_node *np, > > + const char *name, u32 *out_value, > > +u16 out_len); > > +/** > > * dt_property_read_u64 - Helper to read a u64 property. > > * @np: node to get the value > > * @name: name of the property > > > > > -- > Julien Grall
On 11/04/2014 01:55 PM, Frediano Ziglio wrote: >> >> Hi Frediano, >> >> On 11/03/2014 04:46 PM, Frediano Ziglio wrote: >>> From: Zoltan Kiss <zoltan.kiss@linaro.org> >>> >>> Signed-off-by: Zoltan Kiss <zoltan.kiss@huawei.com> >> >> You forgot to keep my reviewed-by from the last version. >> >> Regards, >> > > You sent two mails, on first you add your reviewed-by but on the next one you put some comments so I though your reviewed-by was not valid anymore Fair enough. I tend to keep Reviewed-by/Acked-by for minors changes such as coding style. Anyway: Reviewed-by: Julien Grall <julien.grall@linaro.org> Regards,
diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index f72b2e9..1a886c0 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -160,14 +160,21 @@ const void *dt_get_property(const struct dt_device_node *np, bool_t dt_property_read_u32(const struct dt_device_node *np, const char *name, u32 *out_value) { - u32 len; + return dt_property_read_u32_array(np, name, out_value, 1); +} + +bool_t dt_property_read_u32_array(const struct dt_device_node *np, + const char *name, u32 *out_value, u16 out_len) +{ + u32 len, i; const __be32 *val; val = dt_get_property(np, name, &len); - if ( !val || len < sizeof(*out_value) ) + if ( !val || len < sizeof(*out_value) * out_len ) return 0; - *out_value = be32_to_cpup(val); + for ( i = 0; i < out_len; i++, val++ ) + out_value[i] = be32_to_cpup(val); return 1; } diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 08db8bc..629bfb2 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const struct dt_device_node *np, bool_t dt_property_read_u32(const struct dt_device_node *np, const char *name, u32 *out_value); /** + * dt_property_read_u32_array - Helper to read a u32 array property. + * @np: node to get the value + * @name: name of the property + * @out_value: pointer to return value + * @out_len: length of the array + * + * Return true if get the desired value. + */ +bool_t dt_property_read_u32_array(const struct dt_device_node *np, + const char *name, u32 *out_value, u16 out_len); +/** * dt_property_read_u64 - Helper to read a u64 property. * @np: node to get the value * @name: name of the property