Thread (12 messages) 12 messages, 2 authors, 2013-08-14

Re: [PATCH V5 4/6] of: call __of_parse_phandle_with_args from of_parse_phandle

From: Mark Rutland <mark.rutland@arm.com>
Date: 2013-08-13 09:09:07
Also in: linux-gpio

On Mon, Aug 12, 2013 at 06:36:30PM +0100, Stephen Warren wrote:
From: Stephen Warren <redacted>

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.
quoted hunk ↗ jump to hunk
Signed-off-by: Stephen Warren <redacted>
---
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help