aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/msr.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/kernel/msr.c')
-rw-r--r--arch/i386/kernel/msr.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index d535cdbbfd25..4a472a17d1c6 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -172,7 +172,7 @@ static ssize_t msr_read(struct file *file, char __user * buf,
172 u32 __user *tmp = (u32 __user *) buf; 172 u32 __user *tmp = (u32 __user *) buf;
173 u32 data[2]; 173 u32 data[2];
174 u32 reg = *ppos; 174 u32 reg = *ppos;
175 int cpu = iminor(file->f_dentry->d_inode); 175 int cpu = iminor(file->f_path.dentry->d_inode);
176 int err; 176 int err;
177 177
178 if (count % 8) 178 if (count % 8)
@@ -195,15 +195,14 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
195{ 195{
196 const u32 __user *tmp = (const u32 __user *)buf; 196 const u32 __user *tmp = (const u32 __user *)buf;
197 u32 data[2]; 197 u32 data[2];
198 size_t rv;
199 u32 reg = *ppos; 198 u32 reg = *ppos;
200 int cpu = iminor(file->f_dentry->d_inode); 199 int cpu = iminor(file->f_path.dentry->d_inode);
201 int err; 200 int err;
202 201
203 if (count % 8) 202 if (count % 8)
204 return -EINVAL; /* Invalid chunk size */ 203 return -EINVAL; /* Invalid chunk size */
205 204
206 for (rv = 0; count; count -= 8) { 205 for (; count; count -= 8) {
207 if (copy_from_user(&data, tmp, 8)) 206 if (copy_from_user(&data, tmp, 8))
208 return -EFAULT; 207 return -EFAULT;
209 err = do_wrmsr(cpu, reg, data[0], data[1]); 208 err = do_wrmsr(cpu, reg, data[0], data[1]);
@@ -217,7 +216,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
217 216
218static int msr_open(struct inode *inode, struct file *file) 217static int msr_open(struct inode *inode, struct file *file)
219{ 218{
220 unsigned int cpu = iminor(file->f_dentry->d_inode); 219 unsigned int cpu = iminor(file->f_path.dentry->d_inode);
221 struct cpuinfo_x86 *c = &(cpu_data)[cpu]; 220 struct cpuinfo_x86 *c = &(cpu_data)[cpu];
222 221
223 if (cpu >= NR_CPUS || !cpu_online(cpu)) 222 if (cpu >= NR_CPUS || !cpu_online(cpu))
@@ -239,18 +238,17 @@ static struct file_operations msr_fops = {
239 .open = msr_open, 238 .open = msr_open,
240}; 239};
241 240
242static int msr_class_device_create(int i) 241static int msr_device_create(int i)
243{ 242{
244 int err = 0; 243 int err = 0;
245 struct class_device *class_err; 244 struct device *dev;
246 245
247 class_err = class_device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i); 246 dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), "msr%d",i);
248 if (IS_ERR(class_err)) 247 if (IS_ERR(dev))
249 err = PTR_ERR(class_err); 248 err = PTR_ERR(dev);
250 return err; 249 return err;
251} 250}
252 251
253#ifdef CONFIG_HOTPLUG_CPU
254static int msr_class_cpu_callback(struct notifier_block *nfb, 252static int msr_class_cpu_callback(struct notifier_block *nfb,
255 unsigned long action, void *hcpu) 253 unsigned long action, void *hcpu)
256{ 254{
@@ -258,10 +256,10 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
258 256
259 switch (action) { 257 switch (action) {
260 case CPU_ONLINE: 258 case CPU_ONLINE:
261 msr_class_device_create(cpu); 259 msr_device_create(cpu);
262 break; 260 break;
263 case CPU_DEAD: 261 case CPU_DEAD:
264 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); 262 device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
265 break; 263 break;
266 } 264 }
267 return NOTIFY_OK; 265 return NOTIFY_OK;
@@ -271,7 +269,6 @@ static struct notifier_block __cpuinitdata msr_class_cpu_notifier =
271{ 269{
272 .notifier_call = msr_class_cpu_callback, 270 .notifier_call = msr_class_cpu_callback,
273}; 271};
274#endif
275 272
276static int __init msr_init(void) 273static int __init msr_init(void)
277{ 274{
@@ -290,7 +287,7 @@ static int __init msr_init(void)
290 goto out_chrdev; 287 goto out_chrdev;
291 } 288 }
292 for_each_online_cpu(i) { 289 for_each_online_cpu(i) {
293 err = msr_class_device_create(i); 290 err = msr_device_create(i);
294 if (err != 0) 291 if (err != 0)
295 goto out_class; 292 goto out_class;
296 } 293 }
@@ -302,7 +299,7 @@ static int __init msr_init(void)
302out_class: 299out_class:
303 i = 0; 300 i = 0;
304 for_each_online_cpu(i) 301 for_each_online_cpu(i)
305 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, i)); 302 device_destroy(msr_class, MKDEV(MSR_MAJOR, i));
306 class_destroy(msr_class); 303 class_destroy(msr_class);
307out_chrdev: 304out_chrdev:
308 unregister_chrdev(MSR_MAJOR, "cpu/msr"); 305 unregister_chrdev(MSR_MAJOR, "cpu/msr");
@@ -314,7 +311,7 @@ static void __exit msr_exit(void)
314{ 311{
315 int cpu = 0; 312 int cpu = 0;
316 for_each_online_cpu(cpu) 313 for_each_online_cpu(cpu)
317 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); 314 device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
318 class_destroy(msr_class); 315 class_destroy(msr_class);
319 unregister_chrdev(MSR_MAJOR, "cpu/msr"); 316 unregister_chrdev(MSR_MAJOR, "cpu/msr");
320 unregister_hotcpu_notifier(&msr_class_cpu_notifier); 317 unregister_hotcpu_notifier(&msr_class_cpu_notifier);