microblaze: uaccess: copy_to_user unification

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, April 1, 2010 - 10:59 am

Gitweb:     http://git.kernel.org/linus/cc5a428b7ae9c2d6233b5bf6b3e6fbb24ddd1ed5
Commit:     cc5a428b7ae9c2d6233b5bf6b3e6fbb24ddd1ed5
Parent:     0dcb409de73edeb221aed38d9ff8640cf41ff0de
Author:     Michal Simek <monstr@monstr.eu>
AuthorDate: Mon Mar 22 15:52:53 2010 +0100
Committer:  Michal Simek <monstr@monstr.eu>
CommitDate: Thu Apr 1 08:38:20 2010 +0200

    microblaze: uaccess: copy_to_user unification
    
    noMMU and MMU kernel will use copy copy_tofrom_user
    asm implementation.
    
    Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/include/asm/uaccess.h |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index 6bb9b8f..125e4cf 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -372,19 +372,28 @@ extern long __user_bad(void);
 		? __put_user((x), (ptr)) : -EFAULT;			\
 })
 
+extern unsigned long __copy_tofrom_user(void __user *to,
+		const void __user *from, unsigned long size);
+
 #define __copy_from_user(to, from, n)	copy_from_user((to), (from), (n))
 #define __copy_from_user_inatomic(to, from, n) \
 		copy_from_user((to), (from), (n))
 
-#define copy_to_user(to, from, n)					\
-	(access_ok(VERIFY_WRITE, (to), (n)) ?				\
-		__copy_tofrom_user((void __user *)(to),			\
-			(__force const void __user *)(from), (n))	\
-		: -EFAULT)
-
-#define __copy_to_user(to, from, n)	copy_to_user((to), (from), (n))
+#define __copy_to_user(to, from, n)	\
+	__copy_tofrom_user((void __user *)(to),	\
+			(__force const void __user *)(from), (n))
 #define __copy_to_user_inatomic(to, from, n)	copy_to_user((to), (from), (n))
 
+static inline long copy_to_user(void __user *to,
+		const void *from, unsigned long n)
+{
+	might_sleep();
+	if (access_ok(VERIFY_WRITE, to, n))
+		return __copy_to_user(to, from, n);
+	else
+		return n;
+}
+
 #define copy_from_user(to, from, n)					\
 	(access_ok(VERIFY_READ, (from), (n)) ?				\
 		__copy_tofrom_user((__force void __user *)(to),		\
@@ -402,8 +411,6 @@ extern int __strnlen_user(const char __user *sstr, int len);
 
 #endif /* CONFIG_MMU */
 
-extern unsigned long __copy_tofrom_user(void __user *to,
-		const void __user *from, unsigned long size);
 
 #endif  /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
microblaze: uaccess: copy_to_user unification, Linux Kernel Mailing ..., (Thu Apr 1, 10:59 am)