diff options
Diffstat (limited to 'arch/blackfin/include')
-rw-r--r-- | arch/blackfin/include/asm/uaccess.h | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h index d928b8099056..daf2dc8e98cf 100644 --- a/arch/blackfin/include/asm/uaccess.h +++ b/arch/blackfin/include/asm/uaccess.h | |||
@@ -149,54 +149,42 @@ static inline int bad_user_access_length(void) | |||
149 | : /* no outputs */ \ | 149 | : /* no outputs */ \ |
150 | :"d" (x),"a" (__ptr(p)) : "memory") | 150 | :"d" (x),"a" (__ptr(p)) : "memory") |
151 | 151 | ||
152 | #define get_user(x,p) \ | 152 | #define get_user(x, ptr) \ |
153 | ({ \ | 153 | ({ \ |
154 | int _err = 0; \ | 154 | int _err = 0; \ |
155 | typeof(*(p)) *_p = (p); \ | 155 | unsigned long _val = 0; \ |
156 | if (!access_ok(VERIFY_READ, _p, sizeof(*(_p)))) { \ | 156 | const typeof(*(ptr)) __user *_p = (ptr); \ |
157 | _err = -EFAULT; \ | 157 | const size_t ptr_size = sizeof(*(_p)); \ |
158 | } \ | 158 | if (likely(access_ok(VERIFY_READ, _p, ptr_size))) { \ |
159 | else { \ | 159 | BUILD_BUG_ON(ptr_size >= 8); \ |
160 | switch (sizeof(*(_p))) { \ | 160 | switch (ptr_size) { \ |
161 | case 1: \ | 161 | case 1: \ |
162 | __get_user_asm(x, _p, B,(Z)); \ | 162 | __get_user_asm(_val, _p, B,(Z)); \ |
163 | break; \ | 163 | break; \ |
164 | case 2: \ | 164 | case 2: \ |
165 | __get_user_asm(x, _p, W,(Z)); \ | 165 | __get_user_asm(_val, _p, W,(Z)); \ |
166 | break; \ | 166 | break; \ |
167 | case 4: \ | 167 | case 4: \ |
168 | __get_user_asm(x, _p, , ); \ | 168 | __get_user_asm(_val, _p, , ); \ |
169 | break; \ | 169 | break; \ |
170 | case 8: { \ | 170 | } \ |
171 | unsigned long _xl, _xh; \ | 171 | } else \ |
172 | __get_user_asm(_xl, ((unsigned long *)_p)+0, , ); \ | 172 | _err = -EFAULT; \ |
173 | __get_user_asm(_xh, ((unsigned long *)_p)+1, , ); \ | 173 | x = (typeof(*(ptr)))_val; \ |
174 | ((unsigned long *)&x)[0] = _xl; \ | 174 | _err; \ |
175 | ((unsigned long *)&x)[1] = _xh; \ | 175 | }) |
176 | } break; \ | ||
177 | default: \ | ||
178 | x = 0; \ | ||
179 | printk(KERN_INFO "get_user_bad: %s:%d %s\n", \ | ||
180 | __FILE__, __LINE__, __func__); \ | ||
181 | _err = __get_user_bad(); \ | ||
182 | break; \ | ||
183 | } \ | ||
184 | } \ | ||
185 | _err; \ | ||
186 | }) | ||
187 | 176 | ||
188 | #define __get_user(x,p) get_user(x,p) | 177 | #define __get_user(x,p) get_user(x,p) |
189 | 178 | ||
190 | #define __get_user_bad() (bad_user_access_length(), (-EFAULT)) | 179 | #define __get_user_bad() (bad_user_access_length(), (-EFAULT)) |
191 | 180 | ||
192 | #define __get_user_asm(x,p,bhw,option) \ | 181 | #define __get_user_asm(x, ptr, bhw, option) \ |
193 | { \ | 182 | ({ \ |
194 | unsigned long _tmp; \ | 183 | __asm__ __volatile__ ( \ |
195 | __asm__ ("%0 =" #bhw "[%1]"#option";\n\t" \ | 184 | "%0 =" #bhw "[%1]" #option ";" \ |
196 | : "=d" (_tmp) \ | 185 | : "=d" (x) \ |
197 | : "a" (__ptr(p))); \ | 186 | : "a" (__ptr(ptr))); \ |
198 | (x) = (__typeof__(*(p))) _tmp; \ | 187 | }) |
199 | } | ||
200 | 188 | ||
201 | #define __copy_from_user(to, from, n) copy_from_user(to, from, n) | 189 | #define __copy_from_user(to, from, n) copy_from_user(to, from, n) |
202 | #define __copy_to_user(to, from, n) copy_to_user(to, from, n) | 190 | #define __copy_to_user(to, from, n) copy_to_user(to, from, n) |