]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
sh: make use of for_each_node_by_type()
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 17 Aug 2018 22:44:17 +0000 (15:44 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 17 Aug 2018 23:20:27 +0000 (16:20 -0700)
Instead of open-coding the loop, let's use canned macro.

Also make sure we are not leaking "cpus" node reference.

Link: http://lkml.kernel.org/r/20180624224252.GA220395@dtor-ws
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/sh/boards/of-generic.c

index 46b2481eec9034e1cbb5adbdf4f37cb34d085452..26789ad2819360fc2e480e51185a4c3161cbe972 100644 (file)
@@ -56,15 +56,15 @@ const struct of_cpu_method __cpu_method_of_table_sentinel
 
 static void sh_of_smp_probe(void)
 {
-       struct device_node *np = 0;
-       const char *method = 0;
+       struct device_node *np;
+       const char *method = NULL;
        const struct of_cpu_method *m = __cpu_method_of_table;
 
        pr_info("SH generic board support: scanning for cpus\n");
 
        init_cpu_possible(cpumask_of(0));
 
-       while ((np = of_find_node_by_type(np, "cpu"))) {
+       for_each_node_by_type(np, "cpu") {
                const __be32 *cell = of_get_property(np, "reg", NULL);
                u64 id = -1;
                if (cell) id = of_read_number(cell, of_n_addr_cells(np));
@@ -80,6 +80,7 @@ static void sh_of_smp_probe(void)
        if (!method) {
                np = of_find_node_by_name(NULL, "cpus");
                of_property_read_string(np, "enable-method", &method);
+               of_node_put(np);
        }
 
        pr_info("CPU enable method: %s\n", method);