Commit 1e6760c5 authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

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.
Signed-off-by: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 960c65e8
#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 */
......@@ -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_entry
extern int fixup_exception(struct pt_regs *regs);
#endif /* __ASM_SH_UACCESS_H */
#endif /* __ASM_SH_UACCESS_32_H */
......@@ -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; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment