Commit a43ef7cb authored by Wu Fengguang's avatar Wu Fengguang Committed by james toy

Also rename "len" to "sz". No behavior change.

Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Avi Kivity <avi@qumranet.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 493c1cb9
...@@ -441,19 +441,18 @@ static ssize_t read_kmem(struct file *file, char __user *buf, ...@@ -441,19 +441,18 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
if (!kbuf) if (!kbuf)
return -ENOMEM; return -ENOMEM;
while (count > 0) { while (count > 0) {
int len = size_inside_page(p, count); sz = size_inside_page(p, count);
sz = vread(kbuf, (char *)p, sz);
len = vread(kbuf, (char *)p, len); if (!sz)
if (!len)
break; break;
if (copy_to_user(buf, kbuf, len)) { if (copy_to_user(buf, kbuf, sz)) {
free_page((unsigned long)kbuf); free_page((unsigned long)kbuf);
return -EFAULT; return -EFAULT;
} }
count -= len; count -= sz;
buf += len; buf += sz;
read += len; read += sz;
p += len; p += sz;
} }
free_page((unsigned long)kbuf); free_page((unsigned long)kbuf);
} }
...@@ -523,19 +522,14 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, ...@@ -523,19 +522,14 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
unsigned long p = *ppos; unsigned long p = *ppos;
ssize_t wrote = 0; ssize_t wrote = 0;
ssize_t virtr = 0; ssize_t virtr = 0;
ssize_t written;
char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */ char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
if (p < (unsigned long) high_memory) { if (p < (unsigned long) high_memory) {
unsigned long to_write = min_t(unsigned long, count,
wrote = count; (unsigned long)high_memory - p);
if (count > (unsigned long) high_memory - p) wrote = do_write_kmem((void *)p, p, buf, to_write, ppos);
wrote = (unsigned long) high_memory - p; if (wrote != to_write)
return wrote;
written = do_write_kmem((void*)p, p, buf, wrote, ppos);
if (written != wrote)
return written;
wrote = written;
p += wrote; p += wrote;
buf += wrote; buf += wrote;
count -= wrote; count -= wrote;
...@@ -546,20 +540,20 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, ...@@ -546,20 +540,20 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
if (!kbuf) if (!kbuf)
return wrote ? wrote : -ENOMEM; return wrote ? wrote : -ENOMEM;
while (count > 0) { while (count > 0) {
int len = size_inside_page(p, count); unsigned long sz = size_inside_page(p, count);
written = copy_from_user(kbuf, buf, len); sz = copy_from_user(kbuf, buf, sz);
if (written) { if (sz) {
if (wrote + virtr) if (wrote + virtr)
break; break;
free_page((unsigned long)kbuf); free_page((unsigned long)kbuf);
return -EFAULT; return -EFAULT;
} }
len = vwrite(kbuf, (char *)p, len); sz = vwrite(kbuf, (char *)p, sz);
count -= len; count -= sz;
buf += len; buf += sz;
virtr += len; virtr += sz;
p += len; p += sz;
} }
free_page((unsigned long)kbuf); free_page((unsigned long)kbuf);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment