sh: make copy_to/from_user() static inline
PATCH 1/1 sh: make copy_to/from_user() static inline
This patch changes copy_from_user() and copy_to_user() from macros into static inline functions. This way we can use them as function pointers. Also unify the 64 bit and 32 bit versions.
---
include/asm-sh/uaccess.h | 29 +++++++++++++++++++++++++++++ include/asm-sh/uaccess_32.h | 24 +++--------------------- include/asm-sh/uaccess_64.h | 19 ------------------- 3 files changed, 32 insertions(+), 40 deletions(-)
include/asm-sh/uaccess.h +29 -0
@@ -1,5 +1,34 @@ +#ifndef __ASM_SH_UACCESS_H +#define __ASM_SH_UACCESS_H +#ifdef CONFIG_SUPERH32 # include "uaccess_32.h" #else # include "uaccess_64.h" #endif + +static inline unsigned long +copy_from_user (void *to,const void __user *from,unsigned long n) +{ +unsigned long __copy_from = (unsigned long ) from; +__kernel_size_t __copy_size = (__kernel_size_t ) n; + +if (__copy_size &&__access_ok (__copy_from, __copy_size)) +return __copy_user (to, from, __copy_size); + +return __copy_size; +} + +static inline unsigned long +copy_to_user (void __user *to,const void *from,unsigned long n) +{ +unsigned long __copy_to = (unsigned long ) to; +__kernel_size_t __copy_size = (__kernel_size_t ) n; + +if (__copy_size &&__access_ok (__copy_to, __copy_size)) +return __copy_user (to, from, __copy_size); + +return __copy_size; +} + +#endif /* __ASM_SH_UACCESS_H */
include/asm-sh/uaccess_32.h +3 -21
@@ -10,8 +10,8 @@* Copyright (C) 1996, 1997, 1998 by Ralf Baechle * and i386 version. */ -#ifndef __ASM_SH_UACCESS_H -#define __ASM_SH_UACCESS_H +#ifndef __ASM_SH_UACCESS_32_H +#define __ASM_SH_UACCESS_32_H#include <linux/errno.h> #include <linux/sched.h>
@@ -302,24 +302,6 @@ extern void __put_user_unknown(void);/* Return the number of bytes NOT copied */ __kernel_size_t __copy_user (void *to,const void *from,__kernel_size_t n); -#define copy_to_user (to,from,n) ({ \ -void *__copy_to = (void *) (to); \ -__kernel_size_t __copy_size = (__kernel_size_t) (n); \ -__kernel_size_t __copy_res; \ -if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \ -__copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \ -} else __copy_res = __copy_size; \ -__copy_res; }) - -#define copy_from_user (to,from,n) ({ \ -void *__copy_to = (void *) (to); \ -void *__copy_from = (void *) (from); \ -__kernel_size_t __copy_size = (__kernel_size_t) (n); \ -__kernel_size_t __copy_res; \ -if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \ -__copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \ -} else __copy_res = __copy_size; \ -__copy_res; })static __always_inline unsigned long __copy_from_user (void *to,const void __user *from,unsigned long n)
@@ -507,4 +489,4 @@ struct exception_table_entryextern int fixup_exception (struct pt_regs *regs); -#endif /* __ASM_SH_UACCESS_H */ +#endif /* __ASM_SH_UACCESS_32_H */
include/asm-sh/uaccess_64.h +0 -19
@@ -202,15 +202,6 @@ extern void __put_user_unknown(void);/* XXX: should be such that: 4byte and the rest. */ extern __kernel_size_t __copy_user (void *__to,const void *__from,__kernel_size_t __n); -#define copy_to_user (to,from,n) ({ \ -void *__copy_to = (void *) (to); \ -__kernel_size_t __copy_size = (__kernel_size_t) (n); \ -__kernel_size_t __copy_res; \ -if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \ -__copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \ -} else __copy_res = __copy_size; \ -__copy_res; }) -#define copy_to_user_ret (to,from,n,retval) ({ \ if (copy_to_user(to,from,n)) \ return retval; \
@@ -225,16 +216,6 @@ if (__copy_to_user(to,from,n)) \return retval; \ }) -#define copy_from_user (to,from,n) ({ \ -void *__copy_to = (void *) (to); \ -void *__copy_from = (void *) (from); \ -__kernel_size_t __copy_size = (__kernel_size_t) (n); \ -__kernel_size_t __copy_res; \ -if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \ -__copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \ -} else __copy_res = __copy_size; \ -__copy_res; }) -#define copy_from_user_ret (to,from,n,retval) ({ \ if (copy_from_user(to,from,n)) \ return retval; \
Quoted 3 lines · Magnus Damm
This patch changes
copy_from_user()andcopy_to_user()from macros into static inline functions. This way we can use them as function pointers. Also unify the 64 bit and 32 bit versions.
Quoted 3 lines · Magnus Damm
This patch adds byte support to the sign extension code. Unaligned access traps should never be generated on 8-bit io operations, but we will use this code for trapped io and we do need byte support there.
Quoted 2 lines · Magnus Damm
This patch converts the unaligned access handling code to use
opcode_tinstead of u16. While at it, enable unaligned access handling for sh2a.
Quoted 2 lines · Magnus Damm
Update the defconfigs for r2d-plus and r2d-1 since we now have new drivers for sm501 usb, spi-over-sci and epson r9701 rtc in mainline.
These I've applied, thans. I'll have a look at the trapped I/O V2 bits in the morning.