提交 fa29e97b 编写于 作者: W Wu Fengguang 提交者: Linus Torvalds

/dev/mem: cleanup unxlate_dev_mem_ptr() calls

No behaviour change.

[akpm@linux-foundation.org: cleanuplets]
[akpm@linux-foundation.org: remove unused `ret']
Signed-off-by: NWu Fengguang <fengguang.wu@intel.com>
Acked-by: NAndi Kleen <ak@linux.intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Avi Kivity <avi@qumranet.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 f222318e
...@@ -154,6 +154,8 @@ static ssize_t read_mem(struct file * file, char __user * buf, ...@@ -154,6 +154,8 @@ static ssize_t read_mem(struct file * file, char __user * buf,
#endif #endif
while (count > 0) { while (count > 0) {
unsigned long remaining;
sz = size_inside_page(p, count); sz = size_inside_page(p, count);
if (!range_is_allowed(p >> PAGE_SHIFT, count)) if (!range_is_allowed(p >> PAGE_SHIFT, count))
...@@ -168,12 +170,10 @@ static ssize_t read_mem(struct file * file, char __user * buf, ...@@ -168,12 +170,10 @@ static ssize_t read_mem(struct file * file, char __user * buf,
if (!ptr) if (!ptr)
return -EFAULT; return -EFAULT;
if (copy_to_user(buf, ptr, sz)) { remaining = copy_to_user(buf, ptr, sz);
unxlate_dev_mem_ptr(p, ptr);
return -EFAULT;
}
unxlate_dev_mem_ptr(p, ptr); unxlate_dev_mem_ptr(p, ptr);
if (remaining)
return -EFAULT;
buf += sz; buf += sz;
p += sz; p += sz;
...@@ -231,16 +231,14 @@ static ssize_t write_mem(struct file * file, const char __user * buf, ...@@ -231,16 +231,14 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
} }
copied = copy_from_user(ptr, buf, sz); copied = copy_from_user(ptr, buf, sz);
unxlate_dev_mem_ptr(p, ptr);
if (copied) { if (copied) {
written += sz - copied; written += sz - copied;
unxlate_dev_mem_ptr(p, ptr);
if (written) if (written)
break; break;
return -EFAULT; return -EFAULT;
} }
unxlate_dev_mem_ptr(p, ptr);
buf += sz; buf += sz;
p += sz; p += sz;
count -= sz; count -= sz;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册