Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / arch / powerpc / kernel / sysfs.c
index 0f0c3a9..0104350 100644 (file)
@@ -1,4 +1,3 @@
-#include <linux/config.h>
 #include <linux/sysdev.h>
 #include <linux/cpu.h>
 #include <linux/smp.h>
@@ -65,20 +64,20 @@ static int __init smt_setup(void)
        unsigned int cpu;
 
        if (!cpu_has_feature(CPU_FTR_SMT))
-               return 1;
+               return -ENODEV;
 
        options = find_path_device("/options");
        if (!options)
-               return 1;
+               return -ENODEV;
 
        val = (unsigned int *)get_property(options, "ibm,smt-snooze-delay",
                                           NULL);
        if (!smt_snooze_cmdline && val) {
-               for_each_cpu(cpu)
+               for_each_possible_cpu(cpu)
                        per_cpu(smt_snooze_delay, cpu) = *val;
        }
 
-       return 1;
+       return 0;
 }
 __initcall(smt_setup);
 
@@ -93,7 +92,7 @@ static int __init setup_smt_snooze_delay(char *str)
        smt_snooze_cmdline = 1;
 
        if (get_option(&str, &snooze)) {
-               for_each_cpu(cpu)
+               for_each_possible_cpu(cpu)
                        per_cpu(smt_snooze_delay, cpu) = snooze;
        }
 
@@ -304,31 +303,38 @@ static struct notifier_block __devinitdata sysfs_cpu_nb = {
 /* NUMA stuff */
 
 #ifdef CONFIG_NUMA
-static struct node node_devices[MAX_NUMNODES];
-
 static void register_nodes(void)
 {
        int i;
 
-       for (i = 0; i < MAX_NUMNODES; i++) {
-               if (node_online(i)) {
-                       int p_node = parent_node(i);
-                       struct node *parent = NULL;
+       for (i = 0; i < MAX_NUMNODES; i++)
+               register_one_node(i);
+}
 
-                       if (p_node != i)
-                               parent = &node_devices[p_node];
+int sysfs_add_device_to_node(struct sys_device *dev, int nid)
+{
+       struct node *node = &node_devices[nid];
+       return sysfs_create_link(&node->sysdev.kobj, &dev->kobj,
+                       kobject_name(&dev->kobj));
+}
 
-                       register_node(&node_devices[i], i, parent);
-               }
-       }
+void sysfs_remove_device_from_node(struct sys_device *dev, int nid)
+{
+       struct node *node = &node_devices[nid];
+       sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj));
 }
+
 #else
 static void register_nodes(void)
 {
        return;
 }
+
 #endif
 
+EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
+EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node);
+
 /* Only valid if CPU is present. */
 static ssize_t show_physical_id(struct sys_device *dev, char *buf)
 {
@@ -341,23 +347,13 @@ static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
 static int __init topology_init(void)
 {
        int cpu;
-       struct node *parent = NULL;
 
        register_nodes();
-
        register_cpu_notifier(&sysfs_cpu_nb);
 
-       for_each_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                struct cpu *c = &per_cpu(cpu_devices, cpu);
 
-#ifdef CONFIG_NUMA
-               /* The node to which a cpu belongs can't be known
-                * until the cpu is made present.
-                */
-               parent = NULL;
-               if (cpu_present(cpu))
-                       parent = &node_devices[cpu_to_node(cpu)];
-#endif
                /*
                 * For now, we just see if the system supports making
                 * the RTAS calls for CPU hotplug.  But, there may be a
@@ -369,7 +365,7 @@ static int __init topology_init(void)
                        c->no_control = 1;
 
                if (cpu_online(cpu) || (c->no_control == 0)) {
-                       register_cpu(c, cpu, parent);
+                       register_cpu(c, cpu);
 
                        sysdev_create_file(&c->sysdev, &attr_physical_id);
                }