diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-07-18 06:49:58 +0200 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-07-21 23:18:15 +0200 |
commit | c2d3bffebc2cb651ed33abae2434f85cd503a498 (patch) | |
tree | 2e9d456da9b1dc7437edca0dcb6b7069f24ed5ae /arch/sparc/kernel/devices.c | |
parent | [SPARC]: Initialize iounit spinlock in iounit_init(). (diff) | |
download | linux-c2d3bffebc2cb651ed33abae2434f85cd503a498.tar.xz linux-c2d3bffebc2cb651ed33abae2434f85cd503a498.zip |
[SPARC]: Simplify and correct __cpu_find_by()
By using for_each_node_by_type().
Also, correct a spurioud test in check_cpu_node() on sparc64.
It is only called with nodes that have device_type "cpu".
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/devices.c')
-rw-r--r-- | arch/sparc/kernel/devices.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c index adba9dfee35e..af90a5f9ab57 100644 --- a/arch/sparc/kernel/devices.c +++ b/arch/sparc/kernel/devices.c @@ -15,6 +15,7 @@ #include <asm/page.h> #include <asm/oplib.h> +#include <asm/prom.h> #include <asm/smp.h> #include <asm/system.h> #include <asm/cpudata.h> @@ -34,12 +35,6 @@ static int check_cpu_node(int nd, int *cur_inst, int (*compare)(int, int, void *), void *compare_arg, int *prom_node, int *mid) { - char node_str[128]; - - prom_getstring(nd, "device_type", node_str, sizeof(node_str)); - if (strcmp(node_str, "cpu")) - return -ENODEV; - if (!compare(nd, *cur_inst, compare_arg)) { if (prom_node) *prom_node = nd; @@ -59,20 +54,14 @@ static int check_cpu_node(int nd, int *cur_inst, static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, int *prom_node, int *mid) { - int nd, cur_inst, err; + struct device_node *dp; + int cur_inst; - nd = prom_root_node; cur_inst = 0; - - err = check_cpu_node(nd, &cur_inst, compare, compare_arg, - prom_node, mid); - if (!err) - return 0; - - nd = prom_getchild(nd); - while ((nd = prom_getsibling(nd)) != 0) { - err = check_cpu_node(nd, &cur_inst, compare, compare_arg, - prom_node, mid); + for_each_node_by_type(dp, "cpu") { + int err = check_cpu_node(dp->node, &cur_inst, + compare, compare_arg, + prom_node, mid); if (!err) return 0; } |