Skip to content

Commit bd73d1f

Browse files
robherringbebarino
authored andcommitted
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: Rob Herring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 1949c0e commit bd73d1f

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/clk/mvebu/clk-cpu.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ static void __init of_cpu_clk_setup(struct device_node *node)
168168
struct cpu_clk *cpuclk;
169169
void __iomem *clock_complex_base = of_iomap(node, 0);
170170
void __iomem *pmu_dfs_base = of_iomap(node, 1);
171-
int ncpus = 0;
172-
struct device_node *dn;
171+
int ncpus = num_possible_cpus();
172+
int cpu;
173173

174174
if (clock_complex_base == NULL) {
175175
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)
181181
pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n",
182182
__func__);
183183

184-
for_each_of_cpu_node(dn)
185-
ncpus++;
186-
187184
cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL);
188185
if (WARN_ON(!cpuclk))
189186
goto cpuclk_out;
@@ -192,19 +189,14 @@ static void __init of_cpu_clk_setup(struct device_node *node)
192189
if (WARN_ON(!clks))
193190
goto clks_out;
194191

195-
for_each_of_cpu_node(dn) {
192+
for_each_possible_cpu(cpu) {
196193
struct clk_init_data init;
197194
struct clk *clk;
198195
char *clk_name = kzalloc(5, GFP_KERNEL);
199-
int cpu, err;
200196

201197
if (WARN_ON(!clk_name))
202198
goto bail_out;
203199

204-
err = of_property_read_u32(dn, "reg", &cpu);
205-
if (WARN_ON(err))
206-
goto bail_out;
207-
208200
sprintf(clk_name, "cpu%d", cpu);
209201

210202
cpuclk[cpu].parent_name = of_clk_get_parent_name(node, 0);

0 commit comments

Comments
 (0)