Commit 493c1cb9 authored by Wu Fengguang's avatar Wu Fengguang Committed by james toy

Also convert more size_inside_page() users.

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 2ad73392
...@@ -40,12 +40,9 @@ static inline unsigned long size_inside_page(unsigned long start, ...@@ -40,12 +40,9 @@ static inline unsigned long size_inside_page(unsigned long start,
{ {
unsigned long sz; unsigned long sz;
if (-start & (PAGE_SIZE - 1)) sz = PAGE_SIZE - (start & (PAGE_SIZE - 1));
sz = -start & (PAGE_SIZE - 1);
else
sz = PAGE_SIZE;
return min_t(unsigned long, sz, size); return min(sz, size);
} }
/* /*
...@@ -140,9 +137,7 @@ static ssize_t read_mem(struct file * file, char __user * buf, ...@@ -140,9 +137,7 @@ static ssize_t read_mem(struct file * file, char __user * buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */ /* we don't have page 0 mapped on sparc and m68k.. */
if (p < PAGE_SIZE) { if (p < PAGE_SIZE) {
sz = PAGE_SIZE - p; sz = size_inside_page(p, count);
if (sz > count)
sz = count;
if (sz > 0) { if (sz > 0) {
if (clear_user(buf, sz)) if (clear_user(buf, sz))
return -EFAULT; return -EFAULT;
...@@ -202,9 +197,7 @@ static ssize_t write_mem(struct file * file, const char __user * buf, ...@@ -202,9 +197,7 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */ /* we don't have page 0 mapped on sparc and m68k.. */
if (p < PAGE_SIZE) { if (p < PAGE_SIZE) {
unsigned long sz = PAGE_SIZE - p; sz = size_inside_page(p, count);
if (sz > count)
sz = count;
/* Hmm. Do something? */ /* Hmm. Do something? */
buf += sz; buf += sz;
p += sz; p += sz;
...@@ -413,15 +406,14 @@ static ssize_t read_kmem(struct file *file, char __user *buf, ...@@ -413,15 +406,14 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */ /* we don't have page 0 mapped on sparc and m68k.. */
if (p < PAGE_SIZE && low_count > 0) { if (p < PAGE_SIZE && low_count > 0) {
size_t tmp = PAGE_SIZE - p; sz = size_inside_page(p, low_count);
if (tmp > low_count) tmp = low_count; if (clear_user(buf, sz))
if (clear_user(buf, tmp))
return -EFAULT; return -EFAULT;
buf += tmp; buf += sz;
p += tmp; p += sz;
read += tmp; read += sz;
low_count -= tmp; low_count -= sz;
count -= tmp; count -= sz;
} }
#endif #endif
while (low_count > 0) { while (low_count > 0) {
...@@ -481,9 +473,7 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf, ...@@ -481,9 +473,7 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */ /* we don't have page 0 mapped on sparc and m68k.. */
if (realp < PAGE_SIZE) { if (realp < PAGE_SIZE) {
unsigned long sz = PAGE_SIZE - realp; sz = size_inside_page(realp, count);
if (sz > count)
sz = count;
/* Hmm. Do something? */ /* Hmm. Do something? */
buf += sz; buf += sz;
p += sz; p += sz;
......
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