aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/include/asm/uaccess.h
diff options
context:
space:
mode:
authorMichal Simek <monstr@monstr.eu>2010-03-22 13:39:20 -0400
committerMichal Simek <monstr@monstr.eu>2010-04-01 02:38:22 -0400
commit94804a9b3d0e62096a52fb62afcea32b899380c5 (patch)
tree90b1d8320a839289a209f15cd983babb4ee7997e /arch/microblaze/include/asm/uaccess.h
parentcca79120c253451220e589a104bdeb57e4901871 (diff)
microblaze: uaccess: Unify __copy_tofrom_user
Move to generic location. Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze/include/asm/uaccess.h')
-rw-r--r--arch/microblaze/include/asm/uaccess.h59
1 files changed, 21 insertions, 38 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
114extern 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. */
115static inline unsigned long __must_check __clear_user(void __user *to, 118static 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
325static 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
342extern long strncpy_from_user(char *dst, const char *src, long count); 328extern long strncpy_from_user(char *dst, const char *src, long count);
343extern long strnlen_user(const char *src, long count); 329extern 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
353extern unsigned long __copy_tofrom_user(void __user *to, 339extern 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
343static inline long
344strncpy_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
351extern 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
387extern int __strncpy_user(char *to, const char __user *from, int len);
388
389#define __strncpy_from_user __strncpy_user
390
391static inline long
392strncpy_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
399extern 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