2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 11:44:01 +08:00

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>
This commit is contained in:
H. Peter Anvin 2008-08-25 17:35:25 -07:00
parent 85f1cb6015
commit 9ea2b82ed6

View File

@ -89,7 +89,8 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
struct cpuid_regs cmd; struct cpuid_regs cmd;
int cpu = iminor(file->f_path.dentry->d_inode); int cpu = iminor(file->f_path.dentry->d_inode);
u64 pos = *ppos; u64 pos = *ppos;
int err; ssize_t bytes = 0;
int err = 0;
if (count % 16) if (count % 16)
return -EINVAL; /* Invalid chunk size */ return -EINVAL; /* Invalid chunk size */
@ -99,14 +100,17 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
cmd.ecx = pos >> 32; cmd.ecx = pos >> 32;
err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1); err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1);
if (err) if (err)
return err; break;
if (copy_to_user(tmp, &cmd, 16)) if (copy_to_user(tmp, &cmd, 16)) {
return -EFAULT; err = -EFAULT;
break;
}
tmp += 16; tmp += 16;
bytes += 16;
*ppos = ++pos; *ppos = ++pos;
} }
return tmp - buf; return bytes ? bytes : err;
} }
static int cpuid_open(struct inode *inode, struct file *file) static int cpuid_open(struct inode *inode, struct file *file)