Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176236
b: refs/heads/master
c: 7fabadd
h: refs/heads/master
v: v3
  • Loading branch information
Wu Fengguang authored and Linus Torvalds committed Dec 15, 2009
1 parent 86ea9a2 commit d6455ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fa29e97bb8c70fd7f564acbed3422403cee10ab7
refs/heads/master: 7fabaddd09ab32a7c0c08da80315758a2245189d
34 changes: 12 additions & 22 deletions trunk/drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ static inline unsigned long size_inside_page(unsigned long start,
{
unsigned long sz;

if (-start & (PAGE_SIZE - 1))
sz = -start & (PAGE_SIZE - 1);
else
sz = PAGE_SIZE;
sz = PAGE_SIZE - (start & (PAGE_SIZE - 1));

return min_t(unsigned long, sz, size);
return min(sz, size);
}

/*
Expand Down Expand Up @@ -139,9 +136,7 @@ static ssize_t read_mem(struct file * file, char __user * buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */
if (p < PAGE_SIZE) {
sz = PAGE_SIZE - p;
if (sz > count)
sz = count;
sz = size_inside_page(p, count);
if (sz > 0) {
if (clear_user(buf, sz))
return -EFAULT;
Expand Down Expand Up @@ -201,9 +196,7 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */
if (p < PAGE_SIZE) {
unsigned long sz = PAGE_SIZE - p;
if (sz > count)
sz = count;
sz = size_inside_page(p, count);
/* Hmm. Do something? */
buf += sz;
p += sz;
Expand Down Expand Up @@ -412,15 +405,14 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */
if (p < PAGE_SIZE && low_count > 0) {
size_t tmp = PAGE_SIZE - p;
if (tmp > low_count) tmp = low_count;
if (clear_user(buf, tmp))
sz = size_inside_page(p, low_count);
if (clear_user(buf, sz))
return -EFAULT;
buf += tmp;
p += tmp;
read += tmp;
low_count -= tmp;
count -= tmp;
buf += sz;
p += sz;
read += sz;
low_count -= sz;
count -= sz;
}
#endif
while (low_count > 0) {
Expand Down Expand Up @@ -480,9 +472,7 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
/* we don't have page 0 mapped on sparc and m68k.. */
if (realp < PAGE_SIZE) {
unsigned long sz = PAGE_SIZE - realp;
if (sz > count)
sz = count;
sz = size_inside_page(realp, count);
/* Hmm. Do something? */
buf += sz;
p += sz;
Expand Down

0 comments on commit d6455ad

Please sign in to comment.