diff options
author | Paul Mundt <lethal@linux-sh.org> | 2008-06-03 06:38:22 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-07-28 05:10:29 -0400 |
commit | 31f6a11fe764dc580b645d7aa878854fa9e85a06 (patch) | |
tree | 5a25c9127545a5e0cdabaa565633b3e8bed4ed3c /include/asm-sh | |
parent | 85247285ea6f6e2087193b2a720404690e9cb1b3 (diff) |
sh: Consolidate addr/access_ok across mmu/nommu on 32bit.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh')
-rw-r--r-- | include/asm-sh/uaccess_32.h | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/include/asm-sh/uaccess_32.h b/include/asm-sh/uaccess_32.h index 0795ee5919d1..44abd1682329 100644 --- a/include/asm-sh/uaccess_32.h +++ b/include/asm-sh/uaccess_32.h | |||
@@ -19,26 +19,8 @@ | |||
19 | #define VERIFY_READ 0 | 19 | #define VERIFY_READ 0 |
20 | #define VERIFY_WRITE 1 | 20 | #define VERIFY_WRITE 1 |
21 | 21 | ||
22 | |||
23 | #if !defined(CONFIG_MMU) | ||
24 | /* NOMMU is always true */ | ||
25 | #define __addr_ok(addr) (1) | ||
26 | |||
27 | /* | ||
28 | * __access_ok: Check if address with size is OK or not. | ||
29 | * | ||
30 | * If we don't have an MMU (or if its disabled) the only thing we really have | ||
31 | * to look out for is if the address resides somewhere outside of what | ||
32 | * available RAM we have. | ||
33 | */ | ||
34 | static inline int __access_ok(unsigned long addr, unsigned long size) | ||
35 | { | ||
36 | return 1; | ||
37 | } | ||
38 | #else /* CONFIG_MMU */ | ||
39 | #define __addr_ok(addr) \ | 22 | #define __addr_ok(addr) \ |
40 | ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg)) | 23 | ((unsigned long __force)(addr) < current_thread_info()->addr_limit.seg) |
41 | |||
42 | 24 | ||
43 | /* | 25 | /* |
44 | * __access_ok: Check if address with size is OK or not. | 26 | * __access_ok: Check if address with size is OK or not. |
@@ -48,23 +30,8 @@ static inline int __access_ok(unsigned long addr, unsigned long size) | |||
48 | * sum := addr + size; carry? --> flag = true; | 30 | * sum := addr + size; carry? --> flag = true; |
49 | * if (sum >= addr_limit) flag = true; | 31 | * if (sum >= addr_limit) flag = true; |
50 | */ | 32 | */ |
51 | static inline int __access_ok(unsigned long addr, unsigned long size) | 33 | #define __access_ok(addr, size) \ |
52 | { | 34 | (__addr_ok((addr) + (size))) |
53 | unsigned long flag, sum; | ||
54 | |||
55 | __asm__("clrt\n\t" | ||
56 | "addc %3, %1\n\t" | ||
57 | "movt %0\n\t" | ||
58 | "cmp/hi %4, %1\n\t" | ||
59 | "rotcl %0" | ||
60 | :"=&r" (flag), "=r" (sum) | ||
61 | :"1" (addr), "r" (size), | ||
62 | "r" (current_thread_info()->addr_limit.seg) | ||
63 | :"t"); | ||
64 | return flag == 0; | ||
65 | } | ||
66 | #endif /* CONFIG_MMU */ | ||
67 | |||
68 | #define access_ok(type, addr, size) \ | 35 | #define access_ok(type, addr, size) \ |
69 | (__chk_user_ptr(addr), \ | 36 | (__chk_user_ptr(addr), \ |
70 | __access_ok((unsigned long __force)(addr), (size))) | 37 | __access_ok((unsigned long __force)(addr), (size))) |