diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/mem.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 868ff2ce1675..be832b6f8279 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -461,7 +461,7 @@ static ssize_t read_kmem(struct file *file, char __user *buf, | |||
461 | 461 | ||
462 | 462 | ||
463 | static inline ssize_t | 463 | static inline ssize_t |
464 | do_write_kmem(void *p, unsigned long realp, const char __user * buf, | 464 | do_write_kmem(unsigned long p, const char __user *buf, |
465 | size_t count, loff_t *ppos) | 465 | size_t count, loff_t *ppos) |
466 | { | 466 | { |
467 | ssize_t written, sz; | 467 | ssize_t written, sz; |
@@ -470,12 +470,11 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf, | |||
470 | written = 0; | 470 | written = 0; |
471 | #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED | 471 | #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED |
472 | /* we don't have page 0 mapped on sparc and m68k.. */ | 472 | /* we don't have page 0 mapped on sparc and m68k.. */ |
473 | if (realp < PAGE_SIZE) { | 473 | if (p < PAGE_SIZE) { |
474 | sz = size_inside_page(realp, count); | 474 | sz = size_inside_page(p, count); |
475 | /* Hmm. Do something? */ | 475 | /* Hmm. Do something? */ |
476 | buf += sz; | 476 | buf += sz; |
477 | p += sz; | 477 | p += sz; |
478 | realp += sz; | ||
479 | count -= sz; | 478 | count -= sz; |
480 | written += sz; | 479 | written += sz; |
481 | } | 480 | } |
@@ -484,14 +483,14 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf, | |||
484 | while (count > 0) { | 483 | while (count > 0) { |
485 | char *ptr; | 484 | char *ptr; |
486 | 485 | ||
487 | sz = size_inside_page(realp, count); | 486 | sz = size_inside_page(p, count); |
488 | 487 | ||
489 | /* | 488 | /* |
490 | * On ia64 if a page has been mapped somewhere as | 489 | * On ia64 if a page has been mapped somewhere as |
491 | * uncached, then it must also be accessed uncached | 490 | * uncached, then it must also be accessed uncached |
492 | * by the kernel or data corruption may occur | 491 | * by the kernel or data corruption may occur |
493 | */ | 492 | */ |
494 | ptr = xlate_dev_kmem_ptr(p); | 493 | ptr = xlate_dev_kmem_ptr((char *)p); |
495 | 494 | ||
496 | copied = copy_from_user(ptr, buf, sz); | 495 | copied = copy_from_user(ptr, buf, sz); |
497 | if (copied) { | 496 | if (copied) { |
@@ -502,7 +501,6 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf, | |||
502 | } | 501 | } |
503 | buf += sz; | 502 | buf += sz; |
504 | p += sz; | 503 | p += sz; |
505 | realp += sz; | ||
506 | count -= sz; | 504 | count -= sz; |
507 | written += sz; | 505 | written += sz; |
508 | } | 506 | } |
@@ -526,7 +524,7 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, | |||
526 | if (p < (unsigned long) high_memory) { | 524 | if (p < (unsigned long) high_memory) { |
527 | unsigned long to_write = min_t(unsigned long, count, | 525 | unsigned long to_write = min_t(unsigned long, count, |
528 | (unsigned long)high_memory - p); | 526 | (unsigned long)high_memory - p); |
529 | wrote = do_write_kmem((void *)p, p, buf, to_write, ppos); | 527 | wrote = do_write_kmem(p, buf, to_write, ppos); |
530 | if (wrote != to_write) | 528 | if (wrote != to_write) |
531 | return wrote; | 529 | return wrote; |
532 | p += wrote; | 530 | p += wrote; |