diff options
author | Magnus Damm <magnus.damm@gmail.com> | 2008-02-07 05:50:52 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-02-14 00:22:09 -0500 |
commit | 1e6760c5c4589d02a6877fb256b99c33dd8f1ede (patch) | |
tree | 7da4be750339a538da9535c38ccdd8e69be61bdf /include | |
parent | 960c65e88452e761e257c6a20062c91c3e7fa5ac (diff) |
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: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-sh/uaccess.h | 29 | ||||
-rw-r--r-- | include/asm-sh/uaccess_32.h | 24 | ||||
-rw-r--r-- | include/asm-sh/uaccess_64.h | 19 |
3 files changed, 32 insertions, 40 deletions
diff --git a/include/asm-sh/uaccess.h b/include/asm-sh/uaccess.h index ff24ce95b238..b3440c305b5d 100644 --- a/include/asm-sh/uaccess.h +++ b/include/asm-sh/uaccess.h | |||
@@ -1,5 +1,34 @@ | |||
1 | #ifndef __ASM_SH_UACCESS_H | ||
2 | #define __ASM_SH_UACCESS_H | ||
3 | |||
1 | #ifdef CONFIG_SUPERH32 | 4 | #ifdef CONFIG_SUPERH32 |
2 | # include "uaccess_32.h" | 5 | # include "uaccess_32.h" |
3 | #else | 6 | #else |
4 | # include "uaccess_64.h" | 7 | # include "uaccess_64.h" |
5 | #endif | 8 | #endif |
9 | |||
10 | static inline unsigned long | ||
11 | copy_from_user(void *to, const void __user *from, unsigned long n) | ||
12 | { | ||
13 | unsigned long __copy_from = (unsigned long) from; | ||
14 | __kernel_size_t __copy_size = (__kernel_size_t) n; | ||
15 | |||
16 | if (__copy_size && __access_ok(__copy_from, __copy_size)) | ||
17 | return __copy_user(to, from, __copy_size); | ||
18 | |||
19 | return __copy_size; | ||
20 | } | ||
21 | |||
22 | static inline unsigned long | ||
23 | copy_to_user(void __user *to, const void *from, unsigned long n) | ||
24 | { | ||
25 | unsigned long __copy_to = (unsigned long) to; | ||
26 | __kernel_size_t __copy_size = (__kernel_size_t) n; | ||
27 | |||
28 | if (__copy_size && __access_ok(__copy_to, __copy_size)) | ||
29 | return __copy_user(to, from, __copy_size); | ||
30 | |||
31 | return __copy_size; | ||
32 | } | ||
33 | |||
34 | #endif /* __ASM_SH_UACCESS_H */ | ||
diff --git a/include/asm-sh/uaccess_32.h b/include/asm-sh/uaccess_32.h index b6082f3c1dc4..c0318b608893 100644 --- a/include/asm-sh/uaccess_32.h +++ b/include/asm-sh/uaccess_32.h | |||
@@ -10,8 +10,8 @@ | |||
10 | * Copyright (C) 1996, 1997, 1998 by Ralf Baechle | 10 | * Copyright (C) 1996, 1997, 1998 by Ralf Baechle |
11 | * and i386 version. | 11 | * and i386 version. |
12 | */ | 12 | */ |
13 | #ifndef __ASM_SH_UACCESS_H | 13 | #ifndef __ASM_SH_UACCESS_32_H |
14 | #define __ASM_SH_UACCESS_H | 14 | #define __ASM_SH_UACCESS_32_H |
15 | 15 | ||
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
@@ -302,24 +302,6 @@ extern void __put_user_unknown(void); | |||
302 | /* Return the number of bytes NOT copied */ | 302 | /* Return the number of bytes NOT copied */ |
303 | __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); | 303 | __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); |
304 | 304 | ||
305 | #define copy_to_user(to,from,n) ({ \ | ||
306 | void *__copy_to = (void *) (to); \ | ||
307 | __kernel_size_t __copy_size = (__kernel_size_t) (n); \ | ||
308 | __kernel_size_t __copy_res; \ | ||
309 | if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \ | ||
310 | __copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \ | ||
311 | } else __copy_res = __copy_size; \ | ||
312 | __copy_res; }) | ||
313 | |||
314 | #define copy_from_user(to,from,n) ({ \ | ||
315 | void *__copy_to = (void *) (to); \ | ||
316 | void *__copy_from = (void *) (from); \ | ||
317 | __kernel_size_t __copy_size = (__kernel_size_t) (n); \ | ||
318 | __kernel_size_t __copy_res; \ | ||
319 | if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \ | ||
320 | __copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \ | ||
321 | } else __copy_res = __copy_size; \ | ||
322 | __copy_res; }) | ||
323 | 305 | ||
324 | static __always_inline unsigned long | 306 | static __always_inline unsigned long |
325 | __copy_from_user(void *to, const void __user *from, unsigned long n) | 307 | __copy_from_user(void *to, const void __user *from, unsigned long n) |
@@ -507,4 +489,4 @@ struct exception_table_entry | |||
507 | 489 | ||
508 | extern int fixup_exception(struct pt_regs *regs); | 490 | extern int fixup_exception(struct pt_regs *regs); |
509 | 491 | ||
510 | #endif /* __ASM_SH_UACCESS_H */ | 492 | #endif /* __ASM_SH_UACCESS_32_H */ |
diff --git a/include/asm-sh/uaccess_64.h b/include/asm-sh/uaccess_64.h index d54ec082d25a..f956b7b316c7 100644 --- a/include/asm-sh/uaccess_64.h +++ b/include/asm-sh/uaccess_64.h | |||
@@ -202,15 +202,6 @@ extern void __put_user_unknown(void); | |||
202 | /* XXX: should be such that: 4byte and the rest. */ | 202 | /* XXX: should be such that: 4byte and the rest. */ |
203 | extern __kernel_size_t __copy_user(void *__to, const void *__from, __kernel_size_t __n); | 203 | extern __kernel_size_t __copy_user(void *__to, const void *__from, __kernel_size_t __n); |
204 | 204 | ||
205 | #define copy_to_user(to,from,n) ({ \ | ||
206 | void *__copy_to = (void *) (to); \ | ||
207 | __kernel_size_t __copy_size = (__kernel_size_t) (n); \ | ||
208 | __kernel_size_t __copy_res; \ | ||
209 | if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \ | ||
210 | __copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \ | ||
211 | } else __copy_res = __copy_size; \ | ||
212 | __copy_res; }) | ||
213 | |||
214 | #define copy_to_user_ret(to,from,n,retval) ({ \ | 205 | #define copy_to_user_ret(to,from,n,retval) ({ \ |
215 | if (copy_to_user(to,from,n)) \ | 206 | if (copy_to_user(to,from,n)) \ |
216 | return retval; \ | 207 | return retval; \ |
@@ -225,16 +216,6 @@ if (__copy_to_user(to,from,n)) \ | |||
225 | return retval; \ | 216 | return retval; \ |
226 | }) | 217 | }) |
227 | 218 | ||
228 | #define copy_from_user(to,from,n) ({ \ | ||
229 | void *__copy_to = (void *) (to); \ | ||
230 | void *__copy_from = (void *) (from); \ | ||
231 | __kernel_size_t __copy_size = (__kernel_size_t) (n); \ | ||
232 | __kernel_size_t __copy_res; \ | ||
233 | if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \ | ||
234 | __copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \ | ||
235 | } else __copy_res = __copy_size; \ | ||
236 | __copy_res; }) | ||
237 | |||
238 | #define copy_from_user_ret(to,from,n,retval) ({ \ | 219 | #define copy_from_user_ret(to,from,n,retval) ({ \ |
239 | if (copy_from_user(to,from,n)) \ | 220 | if (copy_from_user(to,from,n)) \ |
240 | return retval; \ | 221 | return retval; \ |