diff options
Diffstat (limited to 'arch/x86/kernel/cpuid.c')
-rw-r--r-- | arch/x86/kernel/cpuid.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 6a52d4b36a30..8b862d5900fe 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/cpu.h> | 40 | #include <linux/cpu.h> |
41 | #include <linux/notifier.h> | 41 | #include <linux/notifier.h> |
42 | #include <linux/uaccess.h> | 42 | #include <linux/uaccess.h> |
43 | #include <linux/gfp.h> | ||
43 | 44 | ||
44 | #include <asm/processor.h> | 45 | #include <asm/processor.h> |
45 | #include <asm/msr.h> | 46 | #include <asm/msr.h> |
@@ -116,21 +117,16 @@ static int cpuid_open(struct inode *inode, struct file *file) | |||
116 | { | 117 | { |
117 | unsigned int cpu; | 118 | unsigned int cpu; |
118 | struct cpuinfo_x86 *c; | 119 | struct cpuinfo_x86 *c; |
119 | int ret = 0; | ||
120 | |||
121 | lock_kernel(); | ||
122 | 120 | ||
123 | cpu = iminor(file->f_path.dentry->d_inode); | 121 | cpu = iminor(file->f_path.dentry->d_inode); |
124 | if (cpu >= nr_cpu_ids || !cpu_online(cpu)) { | 122 | if (cpu >= nr_cpu_ids || !cpu_online(cpu)) |
125 | ret = -ENXIO; /* No such CPU */ | 123 | return -ENXIO; /* No such CPU */ |
126 | goto out; | 124 | |
127 | } | ||
128 | c = &cpu_data(cpu); | 125 | c = &cpu_data(cpu); |
129 | if (c->cpuid_level < 0) | 126 | if (c->cpuid_level < 0) |
130 | ret = -EIO; /* CPUID not supported */ | 127 | return -EIO; /* CPUID not supported */ |
131 | out: | 128 | |
132 | unlock_kernel(); | 129 | return 0; |
133 | return ret; | ||
134 | } | 130 | } |
135 | 131 | ||
136 | /* | 132 | /* |
@@ -192,7 +188,8 @@ static int __init cpuid_init(void) | |||
192 | int i, err = 0; | 188 | int i, err = 0; |
193 | i = 0; | 189 | i = 0; |
194 | 190 | ||
195 | if (register_chrdev(CPUID_MAJOR, "cpu/cpuid", &cpuid_fops)) { | 191 | if (__register_chrdev(CPUID_MAJOR, 0, NR_CPUS, |
192 | "cpu/cpuid", &cpuid_fops)) { | ||
196 | printk(KERN_ERR "cpuid: unable to get major %d for cpuid\n", | 193 | printk(KERN_ERR "cpuid: unable to get major %d for cpuid\n", |
197 | CPUID_MAJOR); | 194 | CPUID_MAJOR); |
198 | err = -EBUSY; | 195 | err = -EBUSY; |
@@ -221,7 +218,7 @@ out_class: | |||
221 | } | 218 | } |
222 | class_destroy(cpuid_class); | 219 | class_destroy(cpuid_class); |
223 | out_chrdev: | 220 | out_chrdev: |
224 | unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); | 221 | __unregister_chrdev(CPUID_MAJOR, 0, NR_CPUS, "cpu/cpuid"); |
225 | out: | 222 | out: |
226 | return err; | 223 | return err; |
227 | } | 224 | } |
@@ -233,7 +230,7 @@ static void __exit cpuid_exit(void) | |||
233 | for_each_online_cpu(cpu) | 230 | for_each_online_cpu(cpu) |
234 | cpuid_device_destroy(cpu); | 231 | cpuid_device_destroy(cpu); |
235 | class_destroy(cpuid_class); | 232 | class_destroy(cpuid_class); |
236 | unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); | 233 | __unregister_chrdev(CPUID_MAJOR, 0, NR_CPUS, "cpu/cpuid"); |
237 | unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); | 234 | unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); |
238 | } | 235 | } |
239 | 236 | ||