Re: [PATCH 2/3] of: Make of_find_node_by_path() handle /aliases

From: Frank Rowand
Date: Tue May 20 2014 - 22:46:27 EST


On 5/20/2014 7:41 PM, Frank Rowand wrote:



< snip >



> I will reply to this email with an additional patch that restores the

> original behavior.



< snip >



From: Frank Rowand <frank.rowand@xxxxxxxxxxxxxx>

If __of_find_node_by_path() returns parent when the remaining portion of the
path is "/" then the behavior of of_find_node_by_path() has changed.

Previously, adding an extraneous "/" on the end of a path would result
in of_find_node_by_path() not finding a match.

Signed-off-by: Frank Rowand <frank.rowand@xxxxxxxxxxxxxx>
---
drivers/of/base.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

Index: b/drivers/of/base.c
===================================================================
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -778,7 +778,7 @@ static struct device_node *__of_find_nod
int len = strchrnul(path, '/') - path;

if (!len)
- return parent;
+ return NULL;

for_each_child_of_node(parent, child) {
const char *name = strrchr(child->full_name, '/');
@@ -813,6 +813,17 @@ struct device_node *of_find_node_by_path
struct property *pp;
unsigned long flags;

+ if (strcmp(path, "/") == 0) {
+ raw_spin_lock_irqsave(&devtree_lock, flags);
+ for (; np; np = np->allnext) {
+ if (np->full_name && (of_node_cmp(np->full_name, path) == 0)
+ && of_node_get(np))
+ break;
+ }
+ raw_spin_unlock_irqrestore(&devtree_lock, flags);
+ return np;
+ }
+
/* The path could begin with an alias */
if (*path != '/') {
char *p = strchrnul(path, '/');
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/