From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH 09/10] xen/device_tree: Add new helper to read arrays from a DTB Date: Mon, 03 Nov 2014 14:14:21 +0000 Message-ID: <54578DBD.2040002@linaro.org> References: <1415009522-6344-1-git-send-email-frediano.ziglio@huawei.com> <1415009522-6344-10-git-send-email-frediano.ziglio@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1415009522-6344-10-git-send-email-frediano.ziglio@huawei.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Frediano Ziglio , Ian Campbell , Stefano Stabellini , Tim Deegan Cc: Zoltan Kiss , zoltan.kiss@huawei.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Hi Frediano, On 11/03/2014 10:12 AM, Frediano Ziglio wrote: > From: Zoltan Kiss > > Signed-off-by: Zoltan Kiss Reviewed-by: Julien Grall Regards, > --- > xen/common/device_tree.c | 14 ++++++++++---- > xen/include/xen/device_tree.h | 11 +++++++++++ > 2 files changed, 21 insertions(+), 4 deletions(-) > > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c > index f72b2e9..e97c28b 100644 > --- a/xen/common/device_tree.c > +++ b/xen/common/device_tree.c > @@ -160,19 +160,25 @@ 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; > } > > - > bool_t dt_property_read_u64(const struct dt_device_node *np, > const char *name, u64 *out_value) > { > diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h > index 08db8bc..5fcd9c4 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: lenght 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