Commit dd81c8ab authored by Johan Hovold's avatar Johan Hovold Committed by Palmer Dabbelt

riscv: use for_each_of_cpu_node iterator

Use the new for_each_of_cpu_node() helper to iterate over cpu nodes
instead of open coding. Note that this will allow matching also on the
node name instead of the (for FDT) deprecated device_type property.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarPalmer Dabbelt <palmer@sifive.com>
parent e3d794d5
...@@ -28,7 +28,7 @@ bool has_fpu __read_mostly; ...@@ -28,7 +28,7 @@ bool has_fpu __read_mostly;
void riscv_fill_hwcap(void) void riscv_fill_hwcap(void)
{ {
struct device_node *node = NULL; struct device_node *node;
const char *isa; const char *isa;
size_t i; size_t i;
static unsigned long isa2hwcap[256] = {0}; static unsigned long isa2hwcap[256] = {0};
...@@ -46,9 +46,10 @@ void riscv_fill_hwcap(void) ...@@ -46,9 +46,10 @@ void riscv_fill_hwcap(void)
* We don't support running Linux on hertergenous ISA systems. For * We don't support running Linux on hertergenous ISA systems. For
* now, we just check the ISA of the first "okay" processor. * now, we just check the ISA of the first "okay" processor.
*/ */
while ((node = of_find_node_by_type(node, "cpu"))) for_each_of_cpu_node(node) {
if (riscv_of_processor_hartid(node) >= 0) if (riscv_of_processor_hartid(node) >= 0)
break; break;
}
if (!node) { if (!node) {
pr_warn("Unable to find \"cpu\" devicetree entry\n"); pr_warn("Unable to find \"cpu\" devicetree entry\n");
return; return;
......
...@@ -50,12 +50,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) ...@@ -50,12 +50,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
void __init setup_smp(void) void __init setup_smp(void)
{ {
struct device_node *dn = NULL; struct device_node *dn;
int hart; int hart;
bool found_boot_cpu = false; bool found_boot_cpu = false;
int cpuid = 1; int cpuid = 1;
while ((dn = of_find_node_by_type(dn, "cpu"))) { for_each_of_cpu_node(dn) {
hart = riscv_of_processor_hartid(dn); hart = riscv_of_processor_hartid(dn);
if (hart < 0) if (hart < 0)
continue; continue;
......
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