On Mon, Aug 12, 2013 at 06:36:30PM +0100, Stephen Warren wrote: > From: Stephen Warren <swarren@xxxxxxxxxx> > > The simplest case of __of_parse_phandle_with_args() implements > of_parse_phandle(), except that it doesn't return the node referenced by > the phandle. Modify it to do so, and then rewrite of_parse_phandle() to > call __of_parse_phandle_with_args() rather than open-coding the simple > case. That commit message doesn't seem to match the patch (which doesn't modify __of_parse_phandle_with_args). Rather, now that __of_parse_phandle_with_args can handle parsing with a fixed number of argument cells, it's possible to write of_parse_phandle in terms of it. What's the overhead over the old of_parse_phandle? It looks like this is going to do a lot of pointless work beyond what it already does -- parsing each prior entry in the list, and for each prior entry walking the tree in of_find_node_by_phandle. Maybe we don't use long enough phandle lists anywhere for that to be noticeable. Thanks, Mark. > > Signed-off-by: Stephen Warren <swarren@xxxxxxxxxx> > --- > v5: New patch. > --- > drivers/of/base.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index 2f92522..79ed82c 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -1202,14 +1202,16 @@ static int __of_parse_phandle_with_args(const struct device_node *np, > struct device_node *of_parse_phandle(const struct device_node *np, > const char *phandle_name, int index) > { > - const __be32 *phandle; > - int size; > + struct of_phandle_args args; > > - phandle = of_get_property(np, phandle_name, &size); > - if ((!phandle) || (size < sizeof(*phandle) * (index + 1))) > + if (index < 0) > + return NULL; > + > + if (__of_parse_phandle_with_args(np, phandle_name, NULL, 0, > + index, &args)) > return NULL; > > - return of_find_node_by_phandle(be32_to_cpup(phandle + index)); > + return args.np; > } > EXPORT_SYMBOL(of_parse_phandle); > > -- > 1.8.1.5 > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html