diff options
Diffstat (limited to 'drivers/base/cpu.c')
-rw-r--r-- | drivers/base/cpu.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index b79badd0f158..a95844790f7b 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -9,12 +9,15 @@ | |||
9 | #include <linux/topology.h> | 9 | #include <linux/topology.h> |
10 | #include <linux/device.h> | 10 | #include <linux/device.h> |
11 | 11 | ||
12 | #include "base.h" | ||
12 | 13 | ||
13 | struct sysdev_class cpu_sysdev_class = { | 14 | struct sysdev_class cpu_sysdev_class = { |
14 | set_kset_name("cpu"), | 15 | set_kset_name("cpu"), |
15 | }; | 16 | }; |
16 | EXPORT_SYMBOL(cpu_sysdev_class); | 17 | EXPORT_SYMBOL(cpu_sysdev_class); |
17 | 18 | ||
19 | static struct sys_device *cpu_sys_devices[NR_CPUS]; | ||
20 | |||
18 | #ifdef CONFIG_HOTPLUG_CPU | 21 | #ifdef CONFIG_HOTPLUG_CPU |
19 | int __attribute__((weak)) smp_prepare_cpu (int cpu) | 22 | int __attribute__((weak)) smp_prepare_cpu (int cpu) |
20 | { | 23 | { |
@@ -63,6 +66,7 @@ static void __devinit register_cpu_control(struct cpu *cpu) | |||
63 | } | 66 | } |
64 | void unregister_cpu(struct cpu *cpu, struct node *root) | 67 | void unregister_cpu(struct cpu *cpu, struct node *root) |
65 | { | 68 | { |
69 | int logical_cpu = cpu->sysdev.id; | ||
66 | 70 | ||
67 | if (root) | 71 | if (root) |
68 | sysfs_remove_link(&root->sysdev.kobj, | 72 | sysfs_remove_link(&root->sysdev.kobj, |
@@ -70,7 +74,7 @@ void unregister_cpu(struct cpu *cpu, struct node *root) | |||
70 | sysdev_remove_file(&cpu->sysdev, &attr_online); | 74 | sysdev_remove_file(&cpu->sysdev, &attr_online); |
71 | 75 | ||
72 | sysdev_unregister(&cpu->sysdev); | 76 | sysdev_unregister(&cpu->sysdev); |
73 | 77 | cpu_sys_devices[logical_cpu] = NULL; | |
74 | return; | 78 | return; |
75 | } | 79 | } |
76 | #else /* ... !CONFIG_HOTPLUG_CPU */ | 80 | #else /* ... !CONFIG_HOTPLUG_CPU */ |
@@ -102,10 +106,19 @@ int __devinit register_cpu(struct cpu *cpu, int num, struct node *root) | |||
102 | kobject_name(&cpu->sysdev.kobj)); | 106 | kobject_name(&cpu->sysdev.kobj)); |
103 | if (!error && !cpu->no_control) | 107 | if (!error && !cpu->no_control) |
104 | register_cpu_control(cpu); | 108 | register_cpu_control(cpu); |
109 | if (!error) | ||
110 | cpu_sys_devices[num] = &cpu->sysdev; | ||
105 | return error; | 111 | return error; |
106 | } | 112 | } |
107 | 113 | ||
108 | 114 | struct sys_device *get_cpu_sysdev(int cpu) | |
115 | { | ||
116 | if (cpu < NR_CPUS) | ||
117 | return cpu_sys_devices[cpu]; | ||
118 | else | ||
119 | return NULL; | ||
120 | } | ||
121 | EXPORT_SYMBOL_GPL(get_cpu_sysdev); | ||
109 | 122 | ||
110 | int __init cpu_dev_init(void) | 123 | int __init cpu_dev_init(void) |
111 | { | 124 | { |