diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2007-10-19 14:35:03 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2007-10-19 14:35:03 -0400 |
commit | 1f503e7743df91eb6f63af27c310c557edfc3307 (patch) | |
tree | df421c1614981c997b885ae2b3e6425636b1fa6c /arch/x86 | |
parent | 66d16ed45d19600abd72dbd55bd2018437b24b73 (diff) |
i386: do cpuid_device_create() in CPU_UP_PREPARE instead of CPU_ONLINE.
Do cpuid_device_create() in CPU_UP_PREPARE instead of CPU_ONLINE.
[ tglx: arch/x86 adaptation ]
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Gautham R Shenoy <ego@in.ibm.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpuid.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 70dcf912d9fb..2086c727fb09 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c | |||
@@ -134,15 +134,18 @@ static const struct file_operations cpuid_fops = { | |||
134 | .open = cpuid_open, | 134 | .open = cpuid_open, |
135 | }; | 135 | }; |
136 | 136 | ||
137 | static int __cpuinit cpuid_device_create(int i) | 137 | static __cpuinit int cpuid_device_create(int cpu) |
138 | { | 138 | { |
139 | int err = 0; | ||
140 | struct device *dev; | 139 | struct device *dev; |
141 | 140 | ||
142 | dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), "cpu%d",i); | 141 | dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), |
143 | if (IS_ERR(dev)) | 142 | "cpu%d", cpu); |
144 | err = PTR_ERR(dev); | 143 | return IS_ERR(dev) ? PTR_ERR(dev) : 0; |
145 | return err; | 144 | } |
145 | |||
146 | static void cpuid_device_destroy(int cpu) | ||
147 | { | ||
148 | device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); | ||
146 | } | 149 | } |
147 | 150 | ||
148 | static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb, | 151 | static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb, |
@@ -150,18 +153,21 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb, | |||
150 | void *hcpu) | 153 | void *hcpu) |
151 | { | 154 | { |
152 | unsigned int cpu = (unsigned long)hcpu; | 155 | unsigned int cpu = (unsigned long)hcpu; |
156 | int err = 0; | ||
153 | 157 | ||
154 | switch (action) { | 158 | switch (action) { |
155 | case CPU_ONLINE: | 159 | case CPU_UP_PREPARE: |
156 | case CPU_ONLINE_FROZEN: | 160 | case CPU_UP_PREPARE_FROZEN: |
157 | cpuid_device_create(cpu); | 161 | err = cpuid_device_create(cpu); |
158 | break; | 162 | break; |
163 | case CPU_UP_CANCELED: | ||
164 | case CPU_UP_CANCELED_FROZEN: | ||
159 | case CPU_DEAD: | 165 | case CPU_DEAD: |
160 | case CPU_DEAD_FROZEN: | 166 | case CPU_DEAD_FROZEN: |
161 | device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); | 167 | cpuid_device_destroy(cpu); |
162 | break; | 168 | break; |
163 | } | 169 | } |
164 | return NOTIFY_OK; | 170 | return err ? NOTIFY_BAD : NOTIFY_OK; |
165 | } | 171 | } |
166 | 172 | ||
167 | static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier = | 173 | static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier = |
@@ -198,7 +204,7 @@ static int __init cpuid_init(void) | |||
198 | out_class: | 204 | out_class: |
199 | i = 0; | 205 | i = 0; |
200 | for_each_online_cpu(i) { | 206 | for_each_online_cpu(i) { |
201 | device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i)); | 207 | cpuid_device_destroy(i); |
202 | } | 208 | } |
203 | class_destroy(cpuid_class); | 209 | class_destroy(cpuid_class); |
204 | out_chrdev: | 210 | out_chrdev: |
@@ -212,7 +218,7 @@ static void __exit cpuid_exit(void) | |||
212 | int cpu = 0; | 218 | int cpu = 0; |
213 | 219 | ||
214 | for_each_online_cpu(cpu) | 220 | for_each_online_cpu(cpu) |
215 | device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); | 221 | cpuid_device_destroy(cpu); |
216 | class_destroy(cpuid_class); | 222 | class_destroy(cpuid_class); |
217 | unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); | 223 | unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); |
218 | unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); | 224 | unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); |