Commit 3bfb2eaa authored by KAMEZAWA Hiroyuki's avatar KAMEZAWA Hiroyuki Committed by James Toy

Changelov v3->v3.1

 - fixed comments. (mainly vread/vwrite description is updated.)
 - use KM_USER0 instead of KM_USER1
Signed-off-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: default avatarWANG Cong <xiyou.wangcong@gmail.com>
Cc: Mike Smith <scgtrp@gmail.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 85eb70bf
...@@ -1669,10 +1669,13 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) ...@@ -1669,10 +1669,13 @@ static int aligned_vread(char *buf, char *addr, unsigned long count)
* kmap() and get small overhead in this access function. * kmap() and get small overhead in this access function.
*/ */
if (p) { if (p) {
/* we can expect USR1 is not used */ /*
void *map = kmap_atomic(p, KM_USER1); * we can expect USER0 is not used (see vread/vwrite's
* function description)
*/
void *map = kmap_atomic(p, KM_USER0);
memcpy(buf, map + offset, length); memcpy(buf, map + offset, length);
kunmap_atomic(map, KM_USER1); kunmap_atomic(map, KM_USER0);
} else } else
memset(buf, 0, length); memset(buf, 0, length);
...@@ -1705,10 +1708,13 @@ static int aligned_vwrite(char *buf, char *addr, unsigned long count) ...@@ -1705,10 +1708,13 @@ static int aligned_vwrite(char *buf, char *addr, unsigned long count)
* kmap() and get small overhead in this access function. * kmap() and get small overhead in this access function.
*/ */
if (p) { if (p) {
/* we can expect USR1 is not used */ /*
void *map = kmap_atomic(p, KM_USER1); * we can expect USER0 is not used (see vread/vwrite's
* function description)
*/
void *map = kmap_atomic(p, KM_USER0);
memcpy(map + offset, buf, length); memcpy(map + offset, buf, length);
kunmap_atomic(map, KM_USER1); kunmap_atomic(map, KM_USER0);
} }
addr += length; addr += length;
buf += length; buf += length;
...@@ -1725,20 +1731,25 @@ static int aligned_vwrite(char *buf, char *addr, unsigned long count) ...@@ -1725,20 +1731,25 @@ static int aligned_vwrite(char *buf, char *addr, unsigned long count)
* @count: number of bytes to be read. * @count: number of bytes to be read.
* *
* Returns # of bytes which addr and buf should be increased. * Returns # of bytes which addr and buf should be increased.
* (same to count). * (same number to @count). Returns 0 if [addr...addr+count) doesn't
* If [addr...addr+count) doesn't includes any valid area, returns 0. * includes any intersect with alive vmalloc area.
* *
* This function checks that addr is a valid vmalloc'ed area, and * This function checks that addr is a valid vmalloc'ed area, and
* copy data from that area to a given buffer. If the given memory range of * copy data from that area to a given buffer. If the given memory range
* [addr...addr+count) includes some valid address, data is copied to * of [addr...addr+count) includes some valid address, data is copied to
* proper area of @buf. If there are memory holes, they'll be zero-filled. * proper area of @buf. If there are memory holes, they'll be zero-filled.
* IOREMAP area is treated as memory hole and no copy is done. * IOREMAP area is treated as memory hole and no copy is done.
* *
* Note: In usual ops, vread() is never necessary because the caller should * If [addr...addr+count) doesn't includes any intersects with alive
* know vmalloc() area is valid and can use memcpy(). This is for routines * vm_struct area, returns 0.
* which have to access vmalloc area without any informaion, as /dev/kmem. * @buf should be kernel's buffer. Because this function uses KM_USER0,
* the caller should guarantee KM_USER0 is not used.
*
* Note: In usual ops, vread() is never necessary because the caller
* should know vmalloc() area is valid and can use memcpy().
* This is for routines which have to access vmalloc area without
* any informaion, as /dev/kmem.
* *
* The caller should guarantee KM_USER1 is not used.
*/ */
long vread(char *buf, char *addr, unsigned long count) long vread(char *buf, char *addr, unsigned long count)
...@@ -1795,8 +1806,9 @@ finished: ...@@ -1795,8 +1806,9 @@ finished:
* @count: number of bytes to be read. * @count: number of bytes to be read.
* *
* Returns # of bytes which addr and buf should be incresed. * Returns # of bytes which addr and buf should be incresed.
* (same to count). * (same number to @count).
* If [addr...addr+count) doesn't includes any valid area, returns 0. * If [addr...addr+count) doesn't includes any intersect with valid
* vmalloc area, returns 0.
* *
* This function checks that addr is a valid vmalloc'ed area, and * This function checks that addr is a valid vmalloc'ed area, and
* copy data from a buffer to the given addr. If specified range of * copy data from a buffer to the given addr. If specified range of
...@@ -1804,6 +1816,11 @@ finished: ...@@ -1804,6 +1816,11 @@ finished:
* proper area of @buf. If there are memory holes, no copy to hole. * proper area of @buf. If there are memory holes, no copy to hole.
* IOREMAP area is treated as memory hole and no copy is done. * IOREMAP area is treated as memory hole and no copy is done.
* *
* If [addr...addr+count) doesn't includes any intersects with alive
* vm_struct area, returns 0.
* @buf should be kernel's buffer. Because this function uses KM_USER0,
* the caller should guarantee KM_USER0 is not used.
*
* Note: In usual ops, vwrite() is never necessary because the caller * Note: In usual ops, vwrite() is never necessary because the caller
* should know vmalloc() area is valid and can use memcpy(). * should know vmalloc() area is valid and can use memcpy().
* This is for routines which have to access vmalloc area without * This is for routines which have to access vmalloc area without
......
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