Commit 459852bf authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

clk: ti: fix OF child-node lookup

[ Upstream commit 00a461cc ]

Fix child-node lookup which by using the wrong OF helper was searching
the whole tree depth-first, something which could end up matching an
unrelated node.

Also fix the related node-reference leaks.

Fixes: 5b385a45 ("clk: ti: add support for clkctrl aliases")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Acked-by: default avatarTero Kristo <t-kristo@ti.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 1e5ac602
...@@ -129,7 +129,7 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops) ...@@ -129,7 +129,7 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops)
void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) void __init ti_dt_clocks_register(struct ti_dt_clk oclks[])
{ {
struct ti_dt_clk *c; struct ti_dt_clk *c;
struct device_node *node; struct device_node *node, *parent;
struct clk *clk; struct clk *clk;
struct of_phandle_args clkspec; struct of_phandle_args clkspec;
char buf[64]; char buf[64];
...@@ -164,8 +164,12 @@ void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) ...@@ -164,8 +164,12 @@ void __init ti_dt_clocks_register(struct ti_dt_clk oclks[])
continue; continue;
node = of_find_node_by_name(NULL, buf); node = of_find_node_by_name(NULL, buf);
if (num_args) if (num_args) {
node = of_find_node_by_name(node, "clk"); parent = node;
node = of_get_child_by_name(parent, "clk");
of_node_put(parent);
}
clkspec.np = node; clkspec.np = node;
clkspec.args_count = num_args; clkspec.args_count = num_args;
for (i = 0; i < num_args; i++) { for (i = 0; i < num_args; i++) {
...@@ -173,11 +177,12 @@ void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) ...@@ -173,11 +177,12 @@ void __init ti_dt_clocks_register(struct ti_dt_clk oclks[])
if (ret) { if (ret) {
pr_warn("Bad tag in %s at %d: %s\n", pr_warn("Bad tag in %s at %d: %s\n",
c->node_name, i, tags[i]); c->node_name, i, tags[i]);
of_node_put(node);
return; return;
} }
} }
clk = of_clk_get_from_provider(&clkspec); clk = of_clk_get_from_provider(&clkspec);
of_node_put(node);
if (!IS_ERR(clk)) { if (!IS_ERR(clk)) {
c->lk.clk = clk; c->lk.clk = clk;
clkdev_add(&c->lk); clkdev_add(&c->lk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment