]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] fix for register_cpu()
authorAndrew Morton <akpm@osdl.org>
Wed, 22 Oct 2003 01:22:11 +0000 (18:22 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 22 Oct 2003 01:22:11 +0000 (18:22 -0700)
From: jbarnes@sgi.com (Jesse Barnes)

The patch adds a symlink from /sys/devices/system/node/nodeM/cpuN to the
/sys/devices/cpu/cpuN directory so that a userspace program can determine
which CPUs belong to which nodes easily.  Non-NUMA systems can simply pass
NULL in for the root arg and everything will work like it used to.

drivers/base/cpu.c

index 8aa16acfe36bc15194a7a5bb31092faee1684df2..6937604432c5b08450439700b935add3ee751d9f 100644 (file)
@@ -23,10 +23,18 @@ EXPORT_SYMBOL(cpu_sysdev_class);
  */
 int __init register_cpu(struct cpu *cpu, int num, struct node *root)
 {
+       int error;
+
        cpu->node_id = cpu_to_node(num);
        cpu->sysdev.id = num;
        cpu->sysdev.cls = &cpu_sysdev_class;
-       return sys_device_register(&cpu->sysdev);
+
+       error = sys_device_register(&cpu->sysdev);
+       if (!error && root)
+               error = sysfs_create_link(&root->sysdev.kobj,
+                                         &cpu->sysdev.kobj,
+                                         kobject_name(&cpu->sysdev.kobj));
+       return error;
 }