[PATCH] DT: Use helper function to read u32 values

Manjunatha GK manjugk at ti.com
Sat Jul 2 03:44:01 EST 2011


Hi Grant,

On 1 July 2011 20:07, Grant Likely <grant.likely at secretlab.ca> wrote:

> On Fri, Jul 1, 2011 at 7:55 AM, Manjunatha GK <manjugk at ti.com> 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 at ti.com>
> > ---
> >  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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/devicetree-discuss/attachments/20110701/919e24c8/attachment.html>


More information about the devicetree-discuss mailing list