Commit bd73d1fd authored by Rob Herring's avatar Rob Herring Committed by Stephen Boyd

clk: mvebu: Iterate over possible CPUs instead of DT CPU nodes

Rework iterating over DT CPU nodes to iterate over possible CPUs
instead. There's no need to walk the DT CPU nodes again. Possible CPUs
is equal to the number of CPUs defined in the DT. Using the "reg" value
for an array index is fragile as it assumes "reg" is 0-N which often is
not the case.
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230327-mvebu-clk-fixes-v2-3-8333729ee45d@kernel.orgSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 1949c0eb
...@@ -168,8 +168,8 @@ static void __init of_cpu_clk_setup(struct device_node *node) ...@@ -168,8 +168,8 @@ static void __init of_cpu_clk_setup(struct device_node *node)
struct cpu_clk *cpuclk; struct cpu_clk *cpuclk;
void __iomem *clock_complex_base = of_iomap(node, 0); void __iomem *clock_complex_base = of_iomap(node, 0);
void __iomem *pmu_dfs_base = of_iomap(node, 1); void __iomem *pmu_dfs_base = of_iomap(node, 1);
int ncpus = 0; int ncpus = num_possible_cpus();
struct device_node *dn; int cpu;
if (clock_complex_base == NULL) { if (clock_complex_base == NULL) {
pr_err("%s: clock-complex base register not set\n", pr_err("%s: clock-complex base register not set\n",
...@@ -181,9 +181,6 @@ static void __init of_cpu_clk_setup(struct device_node *node) ...@@ -181,9 +181,6 @@ static void __init of_cpu_clk_setup(struct device_node *node)
pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n", pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n",
__func__); __func__);
for_each_of_cpu_node(dn)
ncpus++;
cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL); cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL);
if (WARN_ON(!cpuclk)) if (WARN_ON(!cpuclk))
goto cpuclk_out; goto cpuclk_out;
...@@ -192,19 +189,14 @@ static void __init of_cpu_clk_setup(struct device_node *node) ...@@ -192,19 +189,14 @@ static void __init of_cpu_clk_setup(struct device_node *node)
if (WARN_ON(!clks)) if (WARN_ON(!clks))
goto clks_out; goto clks_out;
for_each_of_cpu_node(dn) { for_each_possible_cpu(cpu) {
struct clk_init_data init; struct clk_init_data init;
struct clk *clk; struct clk *clk;
char *clk_name = kzalloc(5, GFP_KERNEL); char *clk_name = kzalloc(5, GFP_KERNEL);
int cpu, err;
if (WARN_ON(!clk_name)) if (WARN_ON(!clk_name))
goto bail_out; goto bail_out;
err = of_property_read_u32(dn, "reg", &cpu);
if (WARN_ON(err))
goto bail_out;
sprintf(clk_name, "cpu%d", cpu); sprintf(clk_name, "cpu%d", cpu);
cpuclk[cpu].parent_name = of_clk_get_parent_name(node, 0); cpuclk[cpu].parent_name = of_clk_get_parent_name(node, 0);
......
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