Commit 1a4549c1 authored by Stephen Boyd's avatar Stephen Boyd

clk: zx296718: Don't reference clk_init_data after registration

A future patch is going to change semantics of clk_register() so that
clk_hw::init is guaranteed to be NULL after a clk is registered. Avoid
referencing this member here so that we don't run into NULL pointer
exceptions.

Cc: Jun Nie <jun.nie@linaro.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Link: https://lkml.kernel.org/r/20190815160020.183334-3-sboyd@kernel.org
parent c8cec4f4
...@@ -564,6 +564,7 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -564,6 +564,7 @@ static int __init top_clocks_init(struct device_node *np)
{ {
void __iomem *reg_base; void __iomem *reg_base;
int i, ret; int i, ret;
const char *name;
reg_base = of_iomap(np, 0); reg_base = of_iomap(np, 0);
if (!reg_base) { if (!reg_base) {
...@@ -573,11 +574,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -573,11 +574,10 @@ static int __init top_clocks_init(struct device_node *np)
for (i = 0; i < ARRAY_SIZE(zx296718_pll_clk); i++) { for (i = 0; i < ARRAY_SIZE(zx296718_pll_clk); i++) {
zx296718_pll_clk[i].reg_base += (uintptr_t)reg_base; zx296718_pll_clk[i].reg_base += (uintptr_t)reg_base;
name = zx296718_pll_clk[i].hw.init->name;
ret = clk_hw_register(NULL, &zx296718_pll_clk[i].hw); ret = clk_hw_register(NULL, &zx296718_pll_clk[i].hw);
if (ret) { if (ret)
pr_warn("top clk %s init error!\n", pr_warn("top clk %s init error!\n", name);
zx296718_pll_clk[i].hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(top_ffactor_clk); i++) { for (i = 0; i < ARRAY_SIZE(top_ffactor_clk); i++) {
...@@ -585,11 +585,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -585,11 +585,10 @@ static int __init top_clocks_init(struct device_node *np)
top_hw_onecell_data.hws[top_ffactor_clk[i].id] = top_hw_onecell_data.hws[top_ffactor_clk[i].id] =
&top_ffactor_clk[i].factor.hw; &top_ffactor_clk[i].factor.hw;
name = top_ffactor_clk[i].factor.hw.init->name;
ret = clk_hw_register(NULL, &top_ffactor_clk[i].factor.hw); ret = clk_hw_register(NULL, &top_ffactor_clk[i].factor.hw);
if (ret) { if (ret)
pr_warn("top clk %s init error!\n", pr_warn("top clk %s init error!\n", name);
top_ffactor_clk[i].factor.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(top_mux_clk); i++) { for (i = 0; i < ARRAY_SIZE(top_mux_clk); i++) {
...@@ -598,11 +597,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -598,11 +597,10 @@ static int __init top_clocks_init(struct device_node *np)
&top_mux_clk[i].mux.hw; &top_mux_clk[i].mux.hw;
top_mux_clk[i].mux.reg += (uintptr_t)reg_base; top_mux_clk[i].mux.reg += (uintptr_t)reg_base;
name = top_mux_clk[i].mux.hw.init->name;
ret = clk_hw_register(NULL, &top_mux_clk[i].mux.hw); ret = clk_hw_register(NULL, &top_mux_clk[i].mux.hw);
if (ret) { if (ret)
pr_warn("top clk %s init error!\n", pr_warn("top clk %s init error!\n", name);
top_mux_clk[i].mux.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(top_gate_clk); i++) { for (i = 0; i < ARRAY_SIZE(top_gate_clk); i++) {
...@@ -611,11 +609,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -611,11 +609,10 @@ static int __init top_clocks_init(struct device_node *np)
&top_gate_clk[i].gate.hw; &top_gate_clk[i].gate.hw;
top_gate_clk[i].gate.reg += (uintptr_t)reg_base; top_gate_clk[i].gate.reg += (uintptr_t)reg_base;
name = top_gate_clk[i].gate.hw.init->name;
ret = clk_hw_register(NULL, &top_gate_clk[i].gate.hw); ret = clk_hw_register(NULL, &top_gate_clk[i].gate.hw);
if (ret) { if (ret)
pr_warn("top clk %s init error!\n", pr_warn("top clk %s init error!\n", name);
top_gate_clk[i].gate.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(top_div_clk); i++) { for (i = 0; i < ARRAY_SIZE(top_div_clk); i++) {
...@@ -624,11 +621,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -624,11 +621,10 @@ static int __init top_clocks_init(struct device_node *np)
&top_div_clk[i].div.hw; &top_div_clk[i].div.hw;
top_div_clk[i].div.reg += (uintptr_t)reg_base; top_div_clk[i].div.reg += (uintptr_t)reg_base;
name = top_div_clk[i].div.hw.init->name;
ret = clk_hw_register(NULL, &top_div_clk[i].div.hw); ret = clk_hw_register(NULL, &top_div_clk[i].div.hw);
if (ret) { if (ret)
pr_warn("top clk %s init error!\n", pr_warn("top clk %s init error!\n", name);
top_div_clk[i].div.hw.init->name);
}
} }
ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
...@@ -754,6 +750,7 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -754,6 +750,7 @@ static int __init lsp0_clocks_init(struct device_node *np)
{ {
void __iomem *reg_base; void __iomem *reg_base;
int i, ret; int i, ret;
const char *name;
reg_base = of_iomap(np, 0); reg_base = of_iomap(np, 0);
if (!reg_base) { if (!reg_base) {
...@@ -767,11 +764,10 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -767,11 +764,10 @@ static int __init lsp0_clocks_init(struct device_node *np)
&lsp0_mux_clk[i].mux.hw; &lsp0_mux_clk[i].mux.hw;
lsp0_mux_clk[i].mux.reg += (uintptr_t)reg_base; lsp0_mux_clk[i].mux.reg += (uintptr_t)reg_base;
name = lsp0_mux_clk[i].mux.hw.init->name;
ret = clk_hw_register(NULL, &lsp0_mux_clk[i].mux.hw); ret = clk_hw_register(NULL, &lsp0_mux_clk[i].mux.hw);
if (ret) { if (ret)
pr_warn("lsp0 clk %s init error!\n", pr_warn("lsp0 clk %s init error!\n", name);
lsp0_mux_clk[i].mux.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(lsp0_gate_clk); i++) { for (i = 0; i < ARRAY_SIZE(lsp0_gate_clk); i++) {
...@@ -780,11 +776,10 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -780,11 +776,10 @@ static int __init lsp0_clocks_init(struct device_node *np)
&lsp0_gate_clk[i].gate.hw; &lsp0_gate_clk[i].gate.hw;
lsp0_gate_clk[i].gate.reg += (uintptr_t)reg_base; lsp0_gate_clk[i].gate.reg += (uintptr_t)reg_base;
name = lsp0_gate_clk[i].gate.hw.init->name;
ret = clk_hw_register(NULL, &lsp0_gate_clk[i].gate.hw); ret = clk_hw_register(NULL, &lsp0_gate_clk[i].gate.hw);
if (ret) { if (ret)
pr_warn("lsp0 clk %s init error!\n", pr_warn("lsp0 clk %s init error!\n", name);
lsp0_gate_clk[i].gate.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(lsp0_div_clk); i++) { for (i = 0; i < ARRAY_SIZE(lsp0_div_clk); i++) {
...@@ -793,11 +788,10 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -793,11 +788,10 @@ static int __init lsp0_clocks_init(struct device_node *np)
&lsp0_div_clk[i].div.hw; &lsp0_div_clk[i].div.hw;
lsp0_div_clk[i].div.reg += (uintptr_t)reg_base; lsp0_div_clk[i].div.reg += (uintptr_t)reg_base;
name = lsp0_div_clk[i].div.hw.init->name;
ret = clk_hw_register(NULL, &lsp0_div_clk[i].div.hw); ret = clk_hw_register(NULL, &lsp0_div_clk[i].div.hw);
if (ret) { if (ret)
pr_warn("lsp0 clk %s init error!\n", pr_warn("lsp0 clk %s init error!\n", name);
lsp0_div_clk[i].div.hw.init->name);
}
} }
ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
...@@ -862,6 +856,7 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -862,6 +856,7 @@ static int __init lsp1_clocks_init(struct device_node *np)
{ {
void __iomem *reg_base; void __iomem *reg_base;
int i, ret; int i, ret;
const char *name;
reg_base = of_iomap(np, 0); reg_base = of_iomap(np, 0);
if (!reg_base) { if (!reg_base) {
...@@ -875,11 +870,10 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -875,11 +870,10 @@ static int __init lsp1_clocks_init(struct device_node *np)
&lsp0_mux_clk[i].mux.hw; &lsp0_mux_clk[i].mux.hw;
lsp1_mux_clk[i].mux.reg += (uintptr_t)reg_base; lsp1_mux_clk[i].mux.reg += (uintptr_t)reg_base;
name = lsp1_mux_clk[i].mux.hw.init->name;
ret = clk_hw_register(NULL, &lsp1_mux_clk[i].mux.hw); ret = clk_hw_register(NULL, &lsp1_mux_clk[i].mux.hw);
if (ret) { if (ret)
pr_warn("lsp1 clk %s init error!\n", pr_warn("lsp1 clk %s init error!\n", name);
lsp1_mux_clk[i].mux.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(lsp1_gate_clk); i++) { for (i = 0; i < ARRAY_SIZE(lsp1_gate_clk); i++) {
...@@ -888,11 +882,10 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -888,11 +882,10 @@ static int __init lsp1_clocks_init(struct device_node *np)
&lsp1_gate_clk[i].gate.hw; &lsp1_gate_clk[i].gate.hw;
lsp1_gate_clk[i].gate.reg += (uintptr_t)reg_base; lsp1_gate_clk[i].gate.reg += (uintptr_t)reg_base;
name = lsp1_gate_clk[i].gate.hw.init->name;
ret = clk_hw_register(NULL, &lsp1_gate_clk[i].gate.hw); ret = clk_hw_register(NULL, &lsp1_gate_clk[i].gate.hw);
if (ret) { if (ret)
pr_warn("lsp1 clk %s init error!\n", pr_warn("lsp1 clk %s init error!\n", name);
lsp1_gate_clk[i].gate.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(lsp1_div_clk); i++) { for (i = 0; i < ARRAY_SIZE(lsp1_div_clk); i++) {
...@@ -901,11 +894,10 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -901,11 +894,10 @@ static int __init lsp1_clocks_init(struct device_node *np)
&lsp1_div_clk[i].div.hw; &lsp1_div_clk[i].div.hw;
lsp1_div_clk[i].div.reg += (uintptr_t)reg_base; lsp1_div_clk[i].div.reg += (uintptr_t)reg_base;
name = lsp1_div_clk[i].div.hw.init->name;
ret = clk_hw_register(NULL, &lsp1_div_clk[i].div.hw); ret = clk_hw_register(NULL, &lsp1_div_clk[i].div.hw);
if (ret) { if (ret)
pr_warn("lsp1 clk %s init error!\n", pr_warn("lsp1 clk %s init error!\n", name);
lsp1_div_clk[i].div.hw.init->name);
}
} }
ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
...@@ -979,6 +971,7 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -979,6 +971,7 @@ static int __init audio_clocks_init(struct device_node *np)
{ {
void __iomem *reg_base; void __iomem *reg_base;
int i, ret; int i, ret;
const char *name;
reg_base = of_iomap(np, 0); reg_base = of_iomap(np, 0);
if (!reg_base) { if (!reg_base) {
...@@ -992,11 +985,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -992,11 +985,10 @@ static int __init audio_clocks_init(struct device_node *np)
&audio_mux_clk[i].mux.hw; &audio_mux_clk[i].mux.hw;
audio_mux_clk[i].mux.reg += (uintptr_t)reg_base; audio_mux_clk[i].mux.reg += (uintptr_t)reg_base;
name = audio_mux_clk[i].mux.hw.init->name;
ret = clk_hw_register(NULL, &audio_mux_clk[i].mux.hw); ret = clk_hw_register(NULL, &audio_mux_clk[i].mux.hw);
if (ret) { if (ret)
pr_warn("audio clk %s init error!\n", pr_warn("audio clk %s init error!\n", name);
audio_mux_clk[i].mux.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(audio_adiv_clk); i++) { for (i = 0; i < ARRAY_SIZE(audio_adiv_clk); i++) {
...@@ -1005,11 +997,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -1005,11 +997,10 @@ static int __init audio_clocks_init(struct device_node *np)
&audio_adiv_clk[i].hw; &audio_adiv_clk[i].hw;
audio_adiv_clk[i].reg_base += (uintptr_t)reg_base; audio_adiv_clk[i].reg_base += (uintptr_t)reg_base;
name = audio_adiv_clk[i].hw.init->name;
ret = clk_hw_register(NULL, &audio_adiv_clk[i].hw); ret = clk_hw_register(NULL, &audio_adiv_clk[i].hw);
if (ret) { if (ret)
pr_warn("audio clk %s init error!\n", pr_warn("audio clk %s init error!\n", name);
audio_adiv_clk[i].hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(audio_div_clk); i++) { for (i = 0; i < ARRAY_SIZE(audio_div_clk); i++) {
...@@ -1018,11 +1009,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -1018,11 +1009,10 @@ static int __init audio_clocks_init(struct device_node *np)
&audio_div_clk[i].div.hw; &audio_div_clk[i].div.hw;
audio_div_clk[i].div.reg += (uintptr_t)reg_base; audio_div_clk[i].div.reg += (uintptr_t)reg_base;
name = audio_div_clk[i].div.hw.init->name;
ret = clk_hw_register(NULL, &audio_div_clk[i].div.hw); ret = clk_hw_register(NULL, &audio_div_clk[i].div.hw);
if (ret) { if (ret)
pr_warn("audio clk %s init error!\n", pr_warn("audio clk %s init error!\n", name);
audio_div_clk[i].div.hw.init->name);
}
} }
for (i = 0; i < ARRAY_SIZE(audio_gate_clk); i++) { for (i = 0; i < ARRAY_SIZE(audio_gate_clk); i++) {
...@@ -1031,11 +1021,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -1031,11 +1021,10 @@ static int __init audio_clocks_init(struct device_node *np)
&audio_gate_clk[i].gate.hw; &audio_gate_clk[i].gate.hw;
audio_gate_clk[i].gate.reg += (uintptr_t)reg_base; audio_gate_clk[i].gate.reg += (uintptr_t)reg_base;
name = audio_gate_clk[i].gate.hw.init->name;
ret = clk_hw_register(NULL, &audio_gate_clk[i].gate.hw); ret = clk_hw_register(NULL, &audio_gate_clk[i].gate.hw);
if (ret) { if (ret)
pr_warn("audio clk %s init error!\n", pr_warn("audio clk %s init error!\n", name);
audio_gate_clk[i].gate.hw.init->name);
}
} }
ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
......
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