diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-07-18 00:49:58 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-07-21 17:18:15 -0400 |
commit | c2d3bffebc2cb651ed33abae2434f85cd503a498 (patch) | |
tree | 2e9d456da9b1dc7437edca0dcb6b7069f24ed5ae /arch | |
parent | 2f72ba43581890d003427053ebe4dfaa14e5f4b0 (diff) |
[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')
-rw-r--r-- | arch/sparc/kernel/devices.c | 25 | ||||
-rw-r--r-- | arch/sparc64/kernel/devices.c | 3 |
2 files changed, 7 insertions, 21 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 @@ | |||
15 | 15 | ||
16 | #include <asm/page.h> | 16 | #include <asm/page.h> |
17 | #include <asm/oplib.h> | 17 | #include <asm/oplib.h> |
18 | #include <asm/prom.h> | ||
18 | #include <asm/smp.h> | 19 | #include <asm/smp.h> |
19 | #include <asm/system.h> | 20 | #include <asm/system.h> |
20 | #include <asm/cpudata.h> | 21 | #include <asm/cpudata.h> |
@@ -34,12 +35,6 @@ static int check_cpu_node(int nd, int *cur_inst, | |||
34 | int (*compare)(int, int, void *), void *compare_arg, | 35 | int (*compare)(int, int, void *), void *compare_arg, |
35 | int *prom_node, int *mid) | 36 | int *prom_node, int *mid) |
36 | { | 37 | { |
37 | char node_str[128]; | ||
38 | |||
39 | prom_getstring(nd, "device_type", node_str, sizeof(node_str)); | ||
40 | if (strcmp(node_str, "cpu")) | ||
41 | return -ENODEV; | ||
42 | |||
43 | if (!compare(nd, *cur_inst, compare_arg)) { | 38 | if (!compare(nd, *cur_inst, compare_arg)) { |
44 | if (prom_node) | 39 | if (prom_node) |
45 | *prom_node = nd; | 40 | *prom_node = nd; |
@@ -59,20 +54,14 @@ static int check_cpu_node(int nd, int *cur_inst, | |||
59 | static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, | 54 | static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, |
60 | int *prom_node, int *mid) | 55 | int *prom_node, int *mid) |
61 | { | 56 | { |
62 | int nd, cur_inst, err; | 57 | struct device_node *dp; |
58 | int cur_inst; | ||
63 | 59 | ||
64 | nd = prom_root_node; | ||
65 | cur_inst = 0; | 60 | cur_inst = 0; |
66 | 61 | for_each_node_by_type(dp, "cpu") { | |
67 | err = check_cpu_node(nd, &cur_inst, compare, compare_arg, | 62 | int err = check_cpu_node(dp->node, &cur_inst, |
68 | prom_node, mid); | 63 | compare, compare_arg, |
69 | if (!err) | 64 | prom_node, mid); |
70 | return 0; | ||
71 | |||
72 | nd = prom_getchild(nd); | ||
73 | while ((nd = prom_getsibling(nd)) != 0) { | ||
74 | err = check_cpu_node(nd, &cur_inst, compare, compare_arg, | ||
75 | prom_node, mid); | ||
76 | if (!err) | 65 | if (!err) |
77 | return 0; | 66 | return 0; |
78 | } | 67 | } |
diff --git a/arch/sparc64/kernel/devices.c b/arch/sparc64/kernel/devices.c index f8ef2f2b9b37..ec10f7edcf86 100644 --- a/arch/sparc64/kernel/devices.c +++ b/arch/sparc64/kernel/devices.c | |||
@@ -66,9 +66,6 @@ static int check_cpu_node(struct device_node *dp, int *cur_inst, | |||
66 | void *compare_arg, | 66 | void *compare_arg, |
67 | struct device_node **dev_node, int *mid) | 67 | struct device_node **dev_node, int *mid) |
68 | { | 68 | { |
69 | if (strcmp(dp->type, "cpu")) | ||
70 | return -ENODEV; | ||
71 | |||
72 | if (!compare(dp, *cur_inst, compare_arg)) { | 69 | if (!compare(dp, *cur_inst, compare_arg)) { |
73 | if (dev_node) | 70 | if (dev_node) |
74 | *dev_node = dp; | 71 | *dev_node = dp; |