From 5205d08b5f5d8b81b6463d46033a56bec08409cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Tigeot?= Date: Sat, 28 Feb 2015 09:46:22 +0100 Subject: [PATCH] drm: Add asm/uaccess.h functions * __copy_to_user() and __copy_from_user(), obtained from OpenBSD * __copy_to_user_inatomic() and __copy_from_user_inatomic_nocache(), obtained from FreeBSD --- sys/dev/drm/include/asm/uaccess.h | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sys/dev/drm/include/asm/uaccess.h b/sys/dev/drm/include/asm/uaccess.h index e432d52a53..a7d8d83713 100644 --- a/sys/dev/drm/include/asm/uaccess.h +++ b/sys/dev/drm/include/asm/uaccess.h @@ -47,4 +47,40 @@ copy_from_user(void *to, const void *from, unsigned long n) return 0; } +static inline int +__copy_to_user(void *to, const void *from, unsigned len) +{ + if (copyout(from, to, len)) + return len; + return 0; +} + +static inline unsigned long +__copy_from_user(void *to, const void *from, unsigned len) +{ + if (copyin(from, to, len)) + return len; + return 0; +} + +static inline int +__copy_to_user_inatomic(void __user *to, const void *from, unsigned n) +{ + return (copyout_nofault(from, to, n) != 0 ? n : 0); +} + +static inline unsigned long +__copy_from_user_inatomic_nocache(void *to, const void __user *from, + unsigned long n) +{ + /* + * XXXKIB. Equivalent Linux function is implemented using + * MOVNTI for aligned moves. For unaligned head and tail, + * normal move is performed. As such, it is not incorrect, if + * only somewhat slower, to use normal copyin. All uses + * except shmem_pwrite_fast() have the destination mapped WC. + */ + return ((copyin_nofault(__DECONST(void *, from), to, n) != 0 ? n : 0)); +} + #endif /* _ASM_UACCESS_H_ */ -- 2.41.0