aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpuid.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-08-25 20:35:25 -0400
committerH. Peter Anvin <hpa@zytor.com>2008-08-25 20:46:12 -0400
commit9ea2b82ed6265a31f9a84886d74d8a2ef01b27c8 (patch)
treec42e3515b37c0e16e03e230d8cf28d07b240d9b2 /arch/x86/kernel/cpuid.c
parent85f1cb60157e06d9e8996b02fad9ba6964523d75 (diff)
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>
Diffstat (limited to 'arch/x86/kernel/cpuid.c')
-rw-r--r--arch/x86/kernel/cpuid.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 23e8316c8357..8e9cd6a8ec12 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -89,7 +89,8 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
89 struct cpuid_regs cmd; 89 struct cpuid_regs cmd;
90 int cpu = iminor(file->f_path.dentry->d_inode); 90 int cpu = iminor(file->f_path.dentry->d_inode);
91 u64 pos = *ppos; 91 u64 pos = *ppos;
92 int err; 92 ssize_t bytes = 0;
93 int err = 0;
93 94
94 if (count % 16) 95 if (count % 16)
95 return -EINVAL; /* Invalid chunk size */ 96 return -EINVAL; /* Invalid chunk size */
@@ -99,14 +100,17 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
99 cmd.ecx = pos >> 32; 100 cmd.ecx = pos >> 32;
100 err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1); 101 err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1);
101 if (err) 102 if (err)
102 return err; 103 break;
103 if (copy_to_user(tmp, &cmd, 16)) 104 if (copy_to_user(tmp, &cmd, 16)) {
104 return -EFAULT; 105 err = -EFAULT;
106 break;
107 }
105 tmp += 16; 108 tmp += 16;
109 bytes += 16;
106 *ppos = ++pos; 110 *ppos = ++pos;
107 } 111 }
108 112
109 return tmp - buf; 113 return bytes ? bytes : err;
110} 114}
111 115
112static int cpuid_open(struct inode *inode, struct file *file) 116static int cpuid_open(struct inode *inode, struct file *file)