Commit 2cca24b2 authored by Stephen Boyd's avatar Stephen Boyd Committed by Greg Kroah-Hartman

clk: zx296718: Don't reference clk_init_data after registration

[ Upstream commit 1a4549c1 ]

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.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
parent efa0fe4c
...@@ -567,6 +567,7 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -567,6 +567,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) {
...@@ -576,11 +577,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -576,11 +577,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++) {
...@@ -588,11 +588,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -588,11 +588,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++) {
...@@ -601,11 +600,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -601,11 +600,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++) {
...@@ -614,11 +612,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -614,11 +612,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++) {
...@@ -627,11 +624,10 @@ static int __init top_clocks_init(struct device_node *np) ...@@ -627,11 +624,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,
...@@ -757,6 +753,7 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -757,6 +753,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) {
...@@ -770,11 +767,10 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -770,11 +767,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++) {
...@@ -783,11 +779,10 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -783,11 +779,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++) {
...@@ -796,11 +791,10 @@ static int __init lsp0_clocks_init(struct device_node *np) ...@@ -796,11 +791,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,
...@@ -865,6 +859,7 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -865,6 +859,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) {
...@@ -878,11 +873,10 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -878,11 +873,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++) {
...@@ -891,11 +885,10 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -891,11 +885,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++) {
...@@ -904,11 +897,10 @@ static int __init lsp1_clocks_init(struct device_node *np) ...@@ -904,11 +897,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,
...@@ -982,6 +974,7 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -982,6 +974,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) {
...@@ -995,11 +988,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -995,11 +988,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++) {
...@@ -1008,11 +1000,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -1008,11 +1000,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++) {
...@@ -1021,11 +1012,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -1021,11 +1012,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++) {
...@@ -1034,11 +1024,10 @@ static int __init audio_clocks_init(struct device_node *np) ...@@ -1034,11 +1024,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