diff options
author | Rob Herring <robh@kernel.org> | 2017-06-02 12:43:18 -0500 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2017-06-22 12:38:29 -0500 |
commit | 27497e11b56a072dfd80e9f1f229049b2921a1a6 (patch) | |
tree | 99a9bcbc25e186d8f8644945e6fc865e02a60b01 /drivers/of/base.c | |
parent | 95e6b1fa3311c8a7b151d38540695409048d1495 (diff) |
of: find_node_by_full_name rewrite to compare each level
find_node_by_full_name() does the same thing as of_find_node_by_path(),
but takes no locks and doesn't work on aliases. Refactor
of_find_node_opts_by_path() into __of_find_node_by_full_path() and
replace find_node_by_full_name() with it.
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r-- | drivers/of/base.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 74b0a27dab9f..87b4968f3d8f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -780,6 +780,24 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, return NULL; } +struct device_node *__of_find_node_by_full_path(struct device_node *node, + const char *path) +{ + const char *separator = strchr(path, ':'); + + while (node && *path == '/') { + struct device_node *tmp = node; + + path++; /* Increment past '/' delimiter */ + node = __of_find_node_by_path(node, path); + of_node_put(tmp); + path = strchrnul(path, '/'); + if (separator && separator < path) + break; + } + return node; +} + /** * of_find_node_opts_by_path - Find a node matching a full OF path * @path: Either the full path to match, or if the path does not @@ -839,16 +857,7 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt raw_spin_lock_irqsave(&devtree_lock, flags); if (!np) np = of_node_get(of_root); - while (np && *path == '/') { - struct device_node *tmp = np; - - path++; /* Increment past '/' delimiter */ - np = __of_find_node_by_path(np, path); - of_node_put(tmp); - path = strchrnul(path, '/'); - if (separator && separator < path) - break; - } + np = __of_find_node_by_full_path(np, path); raw_spin_unlock_irqrestore(&devtree_lock, flags); return np; } |