]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
riscv: use for_each_of_cpu_node iterator
authorJohan Hovold <johan@kernel.org>
Fri, 18 Jan 2019 14:03:08 +0000 (15:03 +0100)
committerPalmer Dabbelt <palmer@sifive.com>
Mon, 11 Feb 2019 23:35:52 +0000 (15:35 -0800)
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: Johan Hovold <johan@kernel.org>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
arch/riscv/kernel/cpufeature.c
arch/riscv/kernel/smpboot.c

index 4891fd62b95ec62fbbd83d3a7512403471ff3782..e7a4701f02563504f2f8cfd7b773c422b4424fe6 100644 (file)
@@ -28,7 +28,7 @@ bool has_fpu __read_mostly;
 
 void riscv_fill_hwcap(void)
 {
-       struct device_node *node = NULL;
+       struct device_node *node;
        const char *isa;
        size_t i;
        static unsigned long isa2hwcap[256] = {0};
@@ -46,9 +46,10 @@ void riscv_fill_hwcap(void)
         * We don't support running Linux on hertergenous ISA systems.  For
         * 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)
                        break;
+       }
        if (!node) {
                pr_warn("Unable to find \"cpu\" devicetree entry\n");
                return;
index 18cda0e8cf9414310e0ec594ee30360f7938808c..6e2813257e0375304079f28e26936ff4e275107b 100644 (file)
@@ -50,12 +50,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 
 void __init setup_smp(void)
 {
-       struct device_node *dn = NULL;
+       struct device_node *dn;
        int hart;
        bool found_boot_cpu = false;
        int cpuid = 1;
 
-       while ((dn = of_find_node_by_type(dn, "cpu"))) {
+       for_each_of_cpu_node(dn) {
                hart = riscv_of_processor_hartid(dn);
                if (hart < 0)
                        continue;