]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kernel/cpuid.c
Merge branch 'x86/cpu' into x86/core
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / cpuid.c
index 2de5fa2bbf77061c31d686035e0d48ca266c49cf..8e9cd6a8ec120951c4683b410572d63b0c3d0824 100644 (file)
@@ -89,6 +89,8 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
        struct cpuid_regs cmd;
        int cpu = iminor(file->f_path.dentry->d_inode);
        u64 pos = *ppos;
+       ssize_t bytes = 0;
+       int err = 0;
 
        if (count % 16)
                return -EINVAL; /* Invalid chunk size */
@@ -96,14 +98,19 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
        for (; count; count -= 16) {
                cmd.eax = pos;
                cmd.ecx = pos >> 32;
-               smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1);
-               if (copy_to_user(tmp, &cmd, 16))
-                       return -EFAULT;
+               err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1);
+               if (err)
+                       break;
+               if (copy_to_user(tmp, &cmd, 16)) {
+                       err = -EFAULT;
+                       break;
+               }
                tmp += 16;
+               bytes += 16;
                *ppos = ++pos;
        }
 
-       return tmp - buf;
+       return bytes ? bytes : err;
 }
 
 static int cpuid_open(struct inode *inode, struct file *file)
@@ -141,8 +148,8 @@ static __cpuinit int cpuid_device_create(int cpu)
 {
        struct device *dev;
 
-       dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
-                           "cpu%d", cpu);
+       dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
+                                   NULL, "cpu%d", cpu);
        return IS_ERR(dev) ? PTR_ERR(dev) : 0;
 }