summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-12-15 02:58:08 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 17:53:11 +0100
commitfa29e97bb8c70fd7f564acbed3422403cee10ab7 (patch)
tree150cd820e3db75b513cc87e4a9061e35ef5346ac
parent/dev/mem: introduce size_inside_page() (diff)
downloadlinux-fa29e97bb8c70fd7f564acbed3422403cee10ab7.tar.xz
linux-fa29e97bb8c70fd7f564acbed3422403cee10ab7.zip
/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: Wu Fengguang <fengguang.wu@intel.com> Acked-by: Andi 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/mem.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index aaa9c24d4c14..c6b2fbc5ed47 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -154,6 +154,8 @@ static ssize_t read_mem(struct file * file, char __user * buf,
#endif
while (count > 0) {
+ unsigned long remaining;
+
sz = size_inside_page(p, count);
if (!range_is_allowed(p >> PAGE_SHIFT, count))
@@ -168,12 +170,10 @@ static ssize_t read_mem(struct file * file, char __user * buf,
if (!ptr)
return -EFAULT;
- if (copy_to_user(buf, ptr, sz)) {
- unxlate_dev_mem_ptr(p, ptr);
- return -EFAULT;
- }
-
+ remaining = copy_to_user(buf, ptr, sz);
unxlate_dev_mem_ptr(p, ptr);
+ if (remaining)
+ return -EFAULT;
buf += sz;
p += sz;
@@ -231,16 +231,14 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
}
copied = copy_from_user(ptr, buf, sz);
+ unxlate_dev_mem_ptr(p, ptr);
if (copied) {
written += sz - copied;
- unxlate_dev_mem_ptr(p, ptr);
if (written)
break;
return -EFAULT;
}
- unxlate_dev_mem_ptr(p, ptr);
-
buf += sz;
p += sz;
count -= sz;