diff options
| author | Michal Simek <monstr@monstr.eu> | 2010-03-22 13:39:20 -0400 |
|---|---|---|
| committer | Michal Simek <monstr@monstr.eu> | 2010-04-01 02:38:22 -0400 |
| commit | 94804a9b3d0e62096a52fb62afcea32b899380c5 (patch) | |
| tree | 90b1d8320a839289a209f15cd983babb4ee7997e | |
| parent | cca79120c253451220e589a104bdeb57e4901871 (diff) | |
microblaze: uaccess: Unify __copy_tofrom_user
Move to generic location.
Signed-off-by: Michal Simek <monstr@monstr.eu>
| -rw-r--r-- | arch/microblaze/include/asm/uaccess.h | 59 | ||||
| -rw-r--r-- | arch/microblaze/lib/Makefile | 2 |
2 files changed, 22 insertions, 39 deletions
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h index 34b79feb1ff1..b33ab659781e 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h | |||
| @@ -111,6 +111,9 @@ static inline int ___range_ok(unsigned long addr, unsigned long size) | |||
| 111 | # define __EX_TABLE_SECTION ".section .discard,\"a\"\n" | 111 | # define __EX_TABLE_SECTION ".section .discard,\"a\"\n" |
| 112 | #endif | 112 | #endif |
| 113 | 113 | ||
| 114 | extern unsigned long __copy_tofrom_user(void __user *to, | ||
| 115 | const void __user *from, unsigned long size); | ||
| 116 | |||
| 114 | /* Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail. */ | 117 | /* Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail. */ |
| 115 | static inline unsigned long __must_check __clear_user(void __user *to, | 118 | static inline unsigned long __must_check __clear_user(void __user *to, |
| 116 | unsigned long n) | 119 | unsigned long n) |
| @@ -322,23 +325,6 @@ static inline long strncpy_from_user(char *dst, | |||
| 322 | return res; | 325 | return res; |
| 323 | } | 326 | } |
| 324 | 327 | ||
| 325 | static inline unsigned long __copy_tofrom_user(void __user *to, | ||
| 326 | const void __user *from, unsigned long size) | ||
| 327 | { | ||
| 328 | memcpy(to, from, size); | ||
| 329 | return 0; | ||
| 330 | } | ||
| 331 | |||
| 332 | #define copy_to_user(to, from, n) (memcpy((to), (from), (n)), 0) | ||
| 333 | #define copy_from_user(to, from, n) (memcpy((to), (from), (n)), 0) | ||
| 334 | |||
| 335 | #define __copy_to_user(to, from, n) (copy_to_user((to), (from), (n))) | ||
| 336 | #define __copy_from_user(to, from, n) (copy_from_user((to), (from), (n))) | ||
| 337 | #define __copy_to_user_inatomic(to, from, n) \ | ||
| 338 | (__copy_to_user((to), (from), (n))) | ||
| 339 | #define __copy_from_user_inatomic(to, from, n) \ | ||
| 340 | (__copy_from_user((to), (from), (n))) | ||
| 341 | |||
| 342 | extern long strncpy_from_user(char *dst, const char *src, long count); | 328 | extern long strncpy_from_user(char *dst, const char *src, long count); |
| 343 | extern long strnlen_user(const char *src, long count); | 329 | extern long strnlen_user(const char *src, long count); |
| 344 | 330 | ||
| @@ -350,8 +336,24 @@ extern long strnlen_user(const char *src, long count); | |||
| 350 | ? __put_user((x), (ptr)) : -EFAULT; \ | 336 | ? __put_user((x), (ptr)) : -EFAULT; \ |
| 351 | }) | 337 | }) |
| 352 | 338 | ||
| 353 | extern unsigned long __copy_tofrom_user(void __user *to, | 339 | extern int __strncpy_user(char *to, const char __user *from, int len); |
| 354 | const void __user *from, unsigned long size); | 340 | |
| 341 | #define __strncpy_from_user __strncpy_user | ||
| 342 | |||
| 343 | static inline long | ||
| 344 | strncpy_from_user(char *dst, const char __user *src, long count) | ||
| 345 | { | ||
| 346 | if (!access_ok(VERIFY_READ, src, 1)) | ||
| 347 | return -EFAULT; | ||
| 348 | return __strncpy_from_user(dst, src, count); | ||
| 349 | } | ||
| 350 | |||
| 351 | extern int __strnlen_user(const char __user *sstr, int len); | ||
| 352 | |||
| 353 | #define strnlen_user(str, len) \ | ||
| 354 | (access_ok(VERIFY_READ, str, 1) ? __strnlen_user(str, len) : 0) | ||
| 355 | |||
| 356 | #endif /* CONFIG_MMU */ | ||
| 355 | 357 | ||
| 356 | #define __copy_from_user(to, from, n) \ | 358 | #define __copy_from_user(to, from, n) \ |
| 357 | __copy_tofrom_user((__force void __user *)(to), \ | 359 | __copy_tofrom_user((__force void __user *)(to), \ |
| @@ -384,25 +386,6 @@ static inline long copy_to_user(void __user *to, | |||
| 384 | return n; | 386 | return n; |
| 385 | } | 387 | } |
| 386 | 388 | ||
| 387 | extern int __strncpy_user(char *to, const char __user *from, int len); | ||
| 388 | |||
| 389 | #define __strncpy_from_user __strncpy_user | ||
| 390 | |||
| 391 | static inline long | ||
| 392 | strncpy_from_user(char *dst, const char __user *src, long count) | ||
| 393 | { | ||
| 394 | if (!access_ok(VERIFY_READ, src, 1)) | ||
| 395 | return -EFAULT; | ||
| 396 | return __strncpy_from_user(dst, src, count); | ||
| 397 | } | ||
| 398 | |||
| 399 | extern int __strnlen_user(const char __user *sstr, int len); | ||
| 400 | |||
| 401 | #define strnlen_user(str, len) \ | ||
| 402 | (access_ok(VERIFY_READ, str, 1) ? __strnlen_user(str, len) : 0) | ||
| 403 | |||
| 404 | #endif /* CONFIG_MMU */ | ||
| 405 | |||
| 406 | #endif /* __ASSEMBLY__ */ | 389 | #endif /* __ASSEMBLY__ */ |
| 407 | #endif /* __KERNEL__ */ | 390 | #endif /* __KERNEL__ */ |
| 408 | 391 | ||
diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile index 59322a2717ae..4dfe47d3cd91 100644 --- a/arch/microblaze/lib/Makefile +++ b/arch/microblaze/lib/Makefile | |||
| @@ -10,4 +10,4 @@ else | |||
| 10 | lib-y += memcpy.o memmove.o | 10 | lib-y += memcpy.o memmove.o |
| 11 | endif | 11 | endif |
| 12 | 12 | ||
| 13 | lib-$(CONFIG_MMU) += uaccess_old.o | 13 | lib-y += uaccess_old.o |
