linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / sparc / kernel / devices.c
index af90a5f..fcb0c04 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  */
 
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/threads.h>
 #include <linux/string.h>
@@ -15,7 +16,6 @@
 
 #include <asm/page.h>
 #include <asm/oplib.h>
-#include <asm/prom.h>
 #include <asm/smp.h>
 #include <asm/system.h>
 #include <asm/cpudata.h>
@@ -35,6 +35,12 @@ 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;
@@ -54,14 +60,20 @@ 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)
 {
-       struct device_node *dp;
-       int cur_inst;
+       int nd, cur_inst, err;
 
+       nd = prom_root_node;
        cur_inst = 0;
-       for_each_node_by_type(dp, "cpu") {
-               int err = check_cpu_node(dp->node, &cur_inst,
-                                        compare, compare_arg,
-                                        prom_node, mid);
+
+       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);
                if (!err)
                        return 0;
        }