x86: cpuid: correct return value on partial operations

Return the correct return value when the CPUID driver partially
completes a request (we should return the number of bytes actually
read or written, instead of the error code.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>

+9 -5
+9 -5
arch/x86/kernel/cpuid.c
··· 89 89 struct cpuid_regs cmd; 90 90 int cpu = iminor(file->f_path.dentry->d_inode); 91 91 u64 pos = *ppos; 92 - int err; 92 + ssize_t bytes = 0; 93 + int err = 0; 93 94 94 95 if (count % 16) 95 96 return -EINVAL; /* Invalid chunk size */ ··· 100 99 cmd.ecx = pos >> 32; 101 100 err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1); 102 101 if (err) 103 - return err; 104 - if (copy_to_user(tmp, &cmd, 16)) 105 - return -EFAULT; 102 + break; 103 + if (copy_to_user(tmp, &cmd, 16)) { 104 + err = -EFAULT; 105 + break; 106 + } 106 107 tmp += 16; 108 + bytes += 16; 107 109 *ppos = ++pos; 108 110 } 109 111 110 - return tmp - buf; 112 + return bytes ? bytes : err; 111 113 } 112 114 113 115 static int cpuid_open(struct inode *inode, struct file *file)