diff mbox

[1/2] Revert "of: fix handling of '/' in options for of_find_node_by_path()"

Message ID 1426608893-3739-2-git-send-email-leif.lindholm@linaro.org
State New
Headers show

Commit Message

Leif Lindholm March 17, 2015, 4:14 p.m. UTC
This reverts commit 106937e8ccdc
("of: fix handling of '/' in options for of_find_node_by_path()")

This fix breaks handling of strings containing both ':' and '/'.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Fixes: 106937e8ccdc
---
 drivers/of/base.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
diff mbox

Patch

diff --git a/drivers/of/base.c b/drivers/of/base.c
index adb8764..3b1aa08 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -714,17 +714,16 @@  static struct device_node *__of_find_node_by_path(struct device_node *parent,
 						const char *path)
 {
 	struct device_node *child;
-	int len;
-	const char *end;
+	int len = strchrnul(path, '/') - path;
+	int term;
 
-	end = strchr(path, ':');
-	if (!end)
-		end = strchrnul(path, '/');
-
-	len = end - path;
 	if (!len)
 		return NULL;
 
+	term = strchrnul(path, ':') - path;
+	if (term < len)
+		len = term;
+
 	__for_each_child_of_node(parent, child) {
 		const char *name = strrchr(child->full_name, '/');
 		if (WARN(!name, "malformed device_node %s\n", child->full_name))
@@ -769,12 +768,8 @@  struct device_node *of_find_node_opts_by_path(const char *path, const char **opt
 
 	/* The path could begin with an alias */
 	if (*path != '/') {
-		int len;
-		const char *p = separator;
-
-		if (!p)
-			p = strchrnul(path, '/');
-		len = p - path;
+		char *p = strchrnul(path, '/');
+		int len = separator ? separator - path : p - path;
 
 		/* of_aliases must not be NULL */
 		if (!of_aliases)
@@ -799,8 +794,6 @@  struct device_node *of_find_node_opts_by_path(const char *path, const char **opt
 		path++; /* Increment past '/' delimiter */
 		np = __of_find_node_by_path(np, path);
 		path = strchrnul(path, '/');
-		if (separator && separator < path)
-			break;
 	}
 	raw_spin_unlock_irqrestore(&devtree_lock, flags);
 	return np;