Merge branch 'drm-patches' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[pandora-kernel.git] / arch / i386 / kernel / msr.c
index d022cb8..4a472a1 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/config.h>
 
 #include <linux/types.h>
 #include <linux/errno.h>
@@ -173,7 +172,7 @@ static ssize_t msr_read(struct file *file, char __user * buf,
        u32 __user *tmp = (u32 __user *) buf;
        u32 data[2];
        u32 reg = *ppos;
-       int cpu = iminor(file->f_dentry->d_inode);
+       int cpu = iminor(file->f_path.dentry->d_inode);
        int err;
 
        if (count % 8)
@@ -196,15 +195,14 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 {
        const u32 __user *tmp = (const u32 __user *)buf;
        u32 data[2];
-       size_t rv;
        u32 reg = *ppos;
-       int cpu = iminor(file->f_dentry->d_inode);
+       int cpu = iminor(file->f_path.dentry->d_inode);
        int err;
 
        if (count % 8)
                return -EINVAL; /* Invalid chunk size */
 
-       for (rv = 0; count; count -= 8) {
+       for (; count; count -= 8) {
                if (copy_from_user(&data, tmp, 8))
                        return -EFAULT;
                err = do_wrmsr(cpu, reg, data[0], data[1]);
@@ -218,7 +216,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 
 static int msr_open(struct inode *inode, struct file *file)
 {
-       unsigned int cpu = iminor(file->f_dentry->d_inode);
+       unsigned int cpu = iminor(file->f_path.dentry->d_inode);
        struct cpuinfo_x86 *c = &(cpu_data)[cpu];
 
        if (cpu >= NR_CPUS || !cpu_online(cpu))
@@ -240,27 +238,28 @@ static struct file_operations msr_fops = {
        .open = msr_open,
 };
 
-static int msr_class_device_create(int i)
+static int msr_device_create(int i)
 {
        int err = 0;
-       struct class_device *class_err;
+       struct device *dev;
 
-       class_err = class_device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
-       if (IS_ERR(class_err)) 
-               err = PTR_ERR(class_err);
+       dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), "msr%d",i);
+       if (IS_ERR(dev))
+               err = PTR_ERR(dev);
        return err;
 }
 
-static int msr_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+static int msr_class_cpu_callback(struct notifier_block *nfb,
+                               unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
 
        switch (action) {
        case CPU_ONLINE:
-               msr_class_device_create(cpu);
+               msr_device_create(cpu);
                break;
        case CPU_DEAD:
-               class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
+               device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
                break;
        }
        return NOTIFY_OK;
@@ -288,11 +287,11 @@ static int __init msr_init(void)
                goto out_chrdev;
        }
        for_each_online_cpu(i) {
-               err = msr_class_device_create(i);
+               err = msr_device_create(i);
                if (err != 0)
                        goto out_class;
        }
-       register_cpu_notifier(&msr_class_cpu_notifier);
+       register_hotcpu_notifier(&msr_class_cpu_notifier);
 
        err = 0;
        goto out;
@@ -300,7 +299,7 @@ static int __init msr_init(void)
 out_class:
        i = 0;
        for_each_online_cpu(i)
-               class_device_destroy(msr_class, MKDEV(MSR_MAJOR, i));
+               device_destroy(msr_class, MKDEV(MSR_MAJOR, i));
        class_destroy(msr_class);
 out_chrdev:
        unregister_chrdev(MSR_MAJOR, "cpu/msr");
@@ -312,10 +311,10 @@ static void __exit msr_exit(void)
 {
        int cpu = 0;
        for_each_online_cpu(cpu)
-               class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
+               device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
        class_destroy(msr_class);
        unregister_chrdev(MSR_MAJOR, "cpu/msr");
-       unregister_cpu_notifier(&msr_class_cpu_notifier);
+       unregister_hotcpu_notifier(&msr_class_cpu_notifier);
 }
 
 module_init(msr_init);