Commit 3fad4cda authored by zijun_hu's avatar zijun_hu Committed by Marc Zyngier

irqchip/gic-v3: Iterate over possible CPUs by for_each_possible_cpu()

get_cpu_number() doesn't use existing helper to iterate over possible
CPUs, It will cause an error in case of discontinuous @cpu_possible_mask
such as 0b11110001, which can result from a core having failed to come
up on a SMP machine.

Fixed by using existing helper for_each_possible_cpu().
Signed-off-by: default avatarzijun_hu <zijun_hu@htc.com>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
parent 2bd6bf03
...@@ -1042,7 +1042,7 @@ static int get_cpu_number(struct device_node *dn) ...@@ -1042,7 +1042,7 @@ static int get_cpu_number(struct device_node *dn)
{ {
const __be32 *cell; const __be32 *cell;
u64 hwid; u64 hwid;
int i; int cpu;
cell = of_get_property(dn, "reg", NULL); cell = of_get_property(dn, "reg", NULL);
if (!cell) if (!cell)
...@@ -1056,9 +1056,9 @@ static int get_cpu_number(struct device_node *dn) ...@@ -1056,9 +1056,9 @@ static int get_cpu_number(struct device_node *dn)
if (hwid & ~MPIDR_HWID_BITMASK) if (hwid & ~MPIDR_HWID_BITMASK)
return -1; return -1;
for (i = 0; i < num_possible_cpus(); i++) for_each_possible_cpu(cpu)
if (cpu_logical_map(i) == hwid) if (cpu_logical_map(cpu) == hwid)
return i; return cpu;
return -1; return -1;
} }
......
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