diff options
Diffstat (limited to 'arch/i386/kernel/cpuid.c')
-rw-r--r-- | arch/i386/kernel/cpuid.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c index fde8bea85cee..51130b39cd2e 100644 --- a/arch/i386/kernel/cpuid.c +++ b/arch/i386/kernel/cpuid.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/major.h> | 34 | #include <linux/major.h> |
35 | #include <linux/fs.h> | 35 | #include <linux/fs.h> |
36 | #include <linux/smp_lock.h> | 36 | #include <linux/smp_lock.h> |
37 | #include <linux/fs.h> | ||
38 | #include <linux/device.h> | 37 | #include <linux/device.h> |
39 | #include <linux/cpu.h> | 38 | #include <linux/cpu.h> |
40 | #include <linux/notifier.h> | 39 | #include <linux/notifier.h> |
@@ -117,7 +116,7 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, | |||
117 | char __user *tmp = buf; | 116 | char __user *tmp = buf; |
118 | u32 data[4]; | 117 | u32 data[4]; |
119 | u32 reg = *ppos; | 118 | u32 reg = *ppos; |
120 | int cpu = iminor(file->f_dentry->d_inode); | 119 | int cpu = iminor(file->f_path.dentry->d_inode); |
121 | 120 | ||
122 | if (count % 16) | 121 | if (count % 16) |
123 | return -EINVAL; /* Invalid chunk size */ | 122 | return -EINVAL; /* Invalid chunk size */ |
@@ -135,7 +134,7 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, | |||
135 | 134 | ||
136 | static int cpuid_open(struct inode *inode, struct file *file) | 135 | static int cpuid_open(struct inode *inode, struct file *file) |
137 | { | 136 | { |
138 | unsigned int cpu = iminor(file->f_dentry->d_inode); | 137 | unsigned int cpu = iminor(file->f_path.dentry->d_inode); |
139 | struct cpuinfo_x86 *c = &(cpu_data)[cpu]; | 138 | struct cpuinfo_x86 *c = &(cpu_data)[cpu]; |
140 | 139 | ||
141 | if (cpu >= NR_CPUS || !cpu_online(cpu)) | 140 | if (cpu >= NR_CPUS || !cpu_online(cpu)) |
@@ -156,28 +155,27 @@ static struct file_operations cpuid_fops = { | |||
156 | .open = cpuid_open, | 155 | .open = cpuid_open, |
157 | }; | 156 | }; |
158 | 157 | ||
159 | static int cpuid_class_device_create(int i) | 158 | static int cpuid_device_create(int i) |
160 | { | 159 | { |
161 | int err = 0; | 160 | int err = 0; |
162 | struct class_device *class_err; | 161 | struct device *dev; |
163 | 162 | ||
164 | class_err = class_device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i); | 163 | dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), "cpu%d",i); |
165 | if (IS_ERR(class_err)) | 164 | if (IS_ERR(dev)) |
166 | err = PTR_ERR(class_err); | 165 | err = PTR_ERR(dev); |
167 | return err; | 166 | return err; |
168 | } | 167 | } |
169 | 168 | ||
170 | #ifdef CONFIG_HOTPLUG_CPU | ||
171 | static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) | 169 | static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) |
172 | { | 170 | { |
173 | unsigned int cpu = (unsigned long)hcpu; | 171 | unsigned int cpu = (unsigned long)hcpu; |
174 | 172 | ||
175 | switch (action) { | 173 | switch (action) { |
176 | case CPU_ONLINE: | 174 | case CPU_ONLINE: |
177 | cpuid_class_device_create(cpu); | 175 | cpuid_device_create(cpu); |
178 | break; | 176 | break; |
179 | case CPU_DEAD: | 177 | case CPU_DEAD: |
180 | class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); | 178 | device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); |
181 | break; | 179 | break; |
182 | } | 180 | } |
183 | return NOTIFY_OK; | 181 | return NOTIFY_OK; |
@@ -187,7 +185,6 @@ static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier = | |||
187 | { | 185 | { |
188 | .notifier_call = cpuid_class_cpu_callback, | 186 | .notifier_call = cpuid_class_cpu_callback, |
189 | }; | 187 | }; |
190 | #endif /* !CONFIG_HOTPLUG_CPU */ | ||
191 | 188 | ||
192 | static int __init cpuid_init(void) | 189 | static int __init cpuid_init(void) |
193 | { | 190 | { |
@@ -206,7 +203,7 @@ static int __init cpuid_init(void) | |||
206 | goto out_chrdev; | 203 | goto out_chrdev; |
207 | } | 204 | } |
208 | for_each_online_cpu(i) { | 205 | for_each_online_cpu(i) { |
209 | err = cpuid_class_device_create(i); | 206 | err = cpuid_device_create(i); |
210 | if (err != 0) | 207 | if (err != 0) |
211 | goto out_class; | 208 | goto out_class; |
212 | } | 209 | } |
@@ -218,7 +215,7 @@ static int __init cpuid_init(void) | |||
218 | out_class: | 215 | out_class: |
219 | i = 0; | 216 | i = 0; |
220 | for_each_online_cpu(i) { | 217 | for_each_online_cpu(i) { |
221 | class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i)); | 218 | device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i)); |
222 | } | 219 | } |
223 | class_destroy(cpuid_class); | 220 | class_destroy(cpuid_class); |
224 | out_chrdev: | 221 | out_chrdev: |
@@ -232,7 +229,7 @@ static void __exit cpuid_exit(void) | |||
232 | int cpu = 0; | 229 | int cpu = 0; |
233 | 230 | ||
234 | for_each_online_cpu(cpu) | 231 | for_each_online_cpu(cpu) |
235 | class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); | 232 | device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); |
236 | class_destroy(cpuid_class); | 233 | class_destroy(cpuid_class); |
237 | unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); | 234 | unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); |
238 | unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); | 235 | unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); |