diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/cpu.c | 18 | ||||
| -rw-r--r-- | drivers/base/node.c | 36 |
2 files changed, 44 insertions, 10 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index dd712b24ec91..3972d8ac9786 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <linux/cpu.h> | 8 | #include <linux/cpu.h> |
| 9 | #include <linux/topology.h> | 9 | #include <linux/topology.h> |
| 10 | #include <linux/device.h> | 10 | #include <linux/device.h> |
| 11 | #include <linux/node.h> | ||
| 11 | 12 | ||
| 12 | #include "base.h" | 13 | #include "base.h" |
| 13 | 14 | ||
| @@ -57,13 +58,12 @@ static void __devinit register_cpu_control(struct cpu *cpu) | |||
| 57 | { | 58 | { |
| 58 | sysdev_create_file(&cpu->sysdev, &attr_online); | 59 | sysdev_create_file(&cpu->sysdev, &attr_online); |
| 59 | } | 60 | } |
| 60 | void unregister_cpu(struct cpu *cpu, struct node *root) | 61 | void unregister_cpu(struct cpu *cpu) |
| 61 | { | 62 | { |
| 62 | int logical_cpu = cpu->sysdev.id; | 63 | int logical_cpu = cpu->sysdev.id; |
| 63 | 64 | ||
| 64 | if (root) | 65 | unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); |
| 65 | sysfs_remove_link(&root->sysdev.kobj, | 66 | |
| 66 | kobject_name(&cpu->sysdev.kobj)); | ||
| 67 | sysdev_remove_file(&cpu->sysdev, &attr_online); | 67 | sysdev_remove_file(&cpu->sysdev, &attr_online); |
| 68 | 68 | ||
| 69 | sysdev_unregister(&cpu->sysdev); | 69 | sysdev_unregister(&cpu->sysdev); |
| @@ -109,23 +109,21 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); | |||
| 109 | * | 109 | * |
| 110 | * Initialize and register the CPU device. | 110 | * Initialize and register the CPU device. |
| 111 | */ | 111 | */ |
| 112 | int __devinit register_cpu(struct cpu *cpu, int num, struct node *root) | 112 | int __devinit register_cpu(struct cpu *cpu, int num) |
| 113 | { | 113 | { |
| 114 | int error; | 114 | int error; |
| 115 | |||
| 116 | cpu->node_id = cpu_to_node(num); | 115 | cpu->node_id = cpu_to_node(num); |
| 117 | cpu->sysdev.id = num; | 116 | cpu->sysdev.id = num; |
| 118 | cpu->sysdev.cls = &cpu_sysdev_class; | 117 | cpu->sysdev.cls = &cpu_sysdev_class; |
| 119 | 118 | ||
| 120 | error = sysdev_register(&cpu->sysdev); | 119 | error = sysdev_register(&cpu->sysdev); |
| 121 | if (!error && root) | 120 | |
| 122 | error = sysfs_create_link(&root->sysdev.kobj, | ||
| 123 | &cpu->sysdev.kobj, | ||
| 124 | kobject_name(&cpu->sysdev.kobj)); | ||
| 125 | if (!error && !cpu->no_control) | 121 | if (!error && !cpu->no_control) |
| 126 | register_cpu_control(cpu); | 122 | register_cpu_control(cpu); |
| 127 | if (!error) | 123 | if (!error) |
| 128 | cpu_sys_devices[num] = &cpu->sysdev; | 124 | cpu_sys_devices[num] = &cpu->sysdev; |
| 125 | if (!error) | ||
| 126 | register_cpu_under_node(num, cpu_to_node(num)); | ||
| 129 | 127 | ||
| 130 | #ifdef CONFIG_KEXEC | 128 | #ifdef CONFIG_KEXEC |
| 131 | if (!error) | 129 | if (!error) |
diff --git a/drivers/base/node.c b/drivers/base/node.c index cbd0f62b4870..eae2bdc183bb 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/cpumask.h> | 11 | #include <linux/cpumask.h> |
| 12 | #include <linux/topology.h> | 12 | #include <linux/topology.h> |
| 13 | #include <linux/nodemask.h> | 13 | #include <linux/nodemask.h> |
| 14 | #include <linux/cpu.h> | ||
| 14 | 15 | ||
| 15 | static struct sysdev_class node_class = { | 16 | static struct sysdev_class node_class = { |
| 16 | set_kset_name("node"), | 17 | set_kset_name("node"), |
| @@ -192,9 +193,38 @@ void unregister_node(struct node *node) | |||
| 192 | 193 | ||
| 193 | struct node node_devices[MAX_NUMNODES]; | 194 | struct node node_devices[MAX_NUMNODES]; |
| 194 | 195 | ||
| 196 | /* | ||
| 197 | * register cpu under node | ||
| 198 | */ | ||
| 199 | int register_cpu_under_node(unsigned int cpu, unsigned int nid) | ||
| 200 | { | ||
| 201 | if (node_online(nid)) { | ||
| 202 | struct sys_device *obj = get_cpu_sysdev(cpu); | ||
| 203 | if (!obj) | ||
| 204 | return 0; | ||
| 205 | return sysfs_create_link(&node_devices[nid].sysdev.kobj, | ||
| 206 | &obj->kobj, | ||
| 207 | kobject_name(&obj->kobj)); | ||
| 208 | } | ||
| 209 | |||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) | ||
| 214 | { | ||
| 215 | if (node_online(nid)) { | ||
| 216 | struct sys_device *obj = get_cpu_sysdev(cpu); | ||
| 217 | if (obj) | ||
| 218 | sysfs_remove_link(&node_devices[nid].sysdev.kobj, | ||
| 219 | kobject_name(&obj->kobj)); | ||
| 220 | } | ||
| 221 | return 0; | ||
| 222 | } | ||
| 223 | |||
| 195 | int register_one_node(int nid) | 224 | int register_one_node(int nid) |
| 196 | { | 225 | { |
| 197 | int error = 0; | 226 | int error = 0; |
| 227 | int cpu; | ||
| 198 | 228 | ||
| 199 | if (node_online(nid)) { | 229 | if (node_online(nid)) { |
| 200 | int p_node = parent_node(nid); | 230 | int p_node = parent_node(nid); |
| @@ -204,6 +234,12 @@ int register_one_node(int nid) | |||
| 204 | parent = &node_devices[p_node]; | 234 | parent = &node_devices[p_node]; |
| 205 | 235 | ||
| 206 | error = register_node(&node_devices[nid], nid, parent); | 236 | error = register_node(&node_devices[nid], nid, parent); |
| 237 | |||
| 238 | /* link cpu under this node */ | ||
| 239 | for_each_present_cpu(cpu) { | ||
| 240 | if (cpu_to_node(cpu) == nid) | ||
| 241 | register_cpu_under_node(cpu, nid); | ||
| 242 | } | ||
| 207 | } | 243 | } |
| 208 | 244 | ||
| 209 | return error; | 245 | return error; |
