From mboxrd@z Thu Jan 1 00:00:00 1970 From: Manjunatha GK Subject: Re: [PATCH] DT: Use helper function to read u32 values Date: Fri, 1 Jul 2011 23:14:01 +0530 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7398332721780650613==" Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Sender: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org To: Grant Likely Cc: "devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org\"" , linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: devicetree@vger.kernel.org --===============7398332721780650613== Content-Type: multipart/alternative; boundary=0016e6d778da23eb1304a70590f7 --0016e6d778da23eb1304a70590f7 Content-Type: text/plain; charset=ISO-8859-1 Hi Grant, On 1 July 2011 20:07, Grant Likely wrote: > On Fri, Jul 1, 2011 at 7:55 AM, Manjunatha GK wrote: > > Use helper function of_property_read_u32() in place of of_get_property > > and be32_to_cpup() api's for code optimization. > > > > Compile tested the changes. > > > > Signed-off-by: G, Manjunath Kondaiah > > --- > > drivers/of/irq.c | 37 ++++++++++++++++++++++--------------- > > drivers/of/of_i2c.c | 8 +++----- > > drivers/of/of_mdio.c | 16 ++++++---------- > > 3 files changed, 31 insertions(+), 30 deletions(-) > > > > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > > index 9f689f1..13c02e2 100644 > > --- a/drivers/of/irq.c > > +++ b/drivers/of/irq.c > > @@ -59,20 +59,20 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map); > > struct device_node *of_irq_find_parent(struct device_node *child) > > { > > struct device_node *p; > > - const __be32 *parp; > > + u32 *parp = NULL; > > > > if (!of_node_get(child)) > > return NULL; > > > > do { > > - parp = of_get_property(child, "interrupt-parent", NULL); > > + of_property_read_u32(child, "interrupt-parent", parp); > > if (parp == NULL) > > p = of_get_parent(child); > > Hi Manjunatha. > > This won't work. You must pass a valid pointer. It needs to be done this > way; > u32 parp; > if (of_property_read_u32(child, "interrupt-parent", &parp) == 0) { > ... > } else { > ... > } > Thanks for the quick catch. I will fix it. -Manjunath --0016e6d778da23eb1304a70590f7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Grant,

On 1 July 2011 20:07, Grant Lik= ely <gran= t.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
On Fri, Jul 1, 2011 at 7:55 AM, Manjunath= a GK <manjugk-l0cyMroinI0@public.gmane.org> wrote: > Use helper function of_property_read_u32() in place of of_get_property=
> and be32_to_cpup() api's for code optimization.
>
> Compile tested the changes.
>
> Signed-off-by: G, Manjunath Kondaiah <manjugk-l0cyMroinI0@public.gmane.org>
> ---
> =A0drivers/of/irq.c=A0=A0=A0=A0 |=A0=A0 37 ++++++++++++++++++++++-----= ----------
> =A0drivers/of/of_i2c.c=A0 |=A0=A0=A0 8 +++-----
> =A0drivers/of/of_mdio.c |=A0=A0 16 ++++++----------
> =A03 files changed, 31 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 9f689f1..13c02e2 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -59,20 +59,20 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
> =A0struct device_node *of_irq_find_parent(struct device_node *child) > =A0{
> =A0=A0=A0=A0 struct device_node *p;
> -=A0=A0=A0 const __be32 *parp;
> +=A0=A0=A0 u32 *parp =3D NULL;
>
> =A0=A0=A0=A0 if (!of_node_get(child))
> =A0=A0=A0=A0 =A0=A0=A0 return NULL;
>
> =A0=A0=A0=A0 do {
> -=A0=A0=A0 =A0=A0=A0 parp =3D of_get_property(child, "interrupt-p= arent", NULL);
> +=A0=A0=A0 =A0=A0=A0 of_property_read_u32(child, "interrupt-paren= t", parp);
> =A0=A0=A0=A0 =A0=A0=A0 if (parp =3D=3D NULL)
> =A0=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 p =3D of_get_parent(child);

Hi Manjunatha.

This won't work. =A0You must pass a valid pointer. =A0It needs to be do= ne this way;
=A0 =A0 =A0 =A0u32 parp;
=A0 =A0 =A0 =A0if (of_property_read_u32(child, "interrupt-parent"= ;, &parp) =3D=3D 0) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0...
=A0 =A0 =A0 =A0} else {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0...
=A0 =A0 =A0 =A0}
Thanks for the quick catch. I will fix it.

-Manjunath

--0016e6d778da23eb1304a70590f7-- --===============7398332721780650613== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org https://lists.ozlabs.org/listinfo/devicetree-discuss --===============7398332721780650613==--