@@ -715,13 +715,11 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent,
{
struct device_node *child;
int len;
- const char *end;
+ const char *p1, *p2;
- end = strchr(path, ':');
- if (!end)
- end = strchrnul(path, '/');
-
- len = end - path;
+ p1 = strchrnul(path, ':');
+ p2 = strchrnul(path, '/');
+ len = (p1 < p2 ? p1 : p2) - path;
if (!len)
return NULL;
@@ -97,6 +97,11 @@ static void __init of_selftest_find_node_by_name(void)
"option path test, subcase #1 failed\n");
of_node_put(np);
+ np = of_find_node_opts_by_path("/testcase-data/phandle-tests:test/option", &options);
+ selftest(np && !strcmp("test/option", options),
+ "option path test, subcase #2 failed\n");
+ of_node_put(np);
+
np = of_find_node_opts_by_path("/testcase-data:testoption", NULL);
selftest(np, "NULL option path test failed\n");
of_node_put(np);