aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2013-12-17 09:42:23 -0500
committerRalf Baechle <ralf@linux-mips.org>2014-03-26 18:09:15 -0400
commitec56b1d4615ab0b07b29ca6a45543484cfd5e463 (patch)
tree2463339f885d5b4f5eb7631fc9d6e8c076f87e18
parentd84869a19faa0fd541a9d3cc93cfe8ac3f0c4d83 (diff)
MIPS: asm: uaccess: Move duplicated code to common function
Similar to __get_user_* functions, move common code to __put_user_*_common so it can be shared among similar users. Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
-rw-r--r--arch/mips/include/asm/uaccess.h61
1 files changed, 29 insertions, 32 deletions
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
index 5ba393392ce3..0df57e783960 100644
--- a/arch/mips/include/asm/uaccess.h
+++ b/arch/mips/include/asm/uaccess.h
@@ -326,13 +326,8 @@ do { \
326#define __PUT_USER_DW(insn, ptr) __put_user_asm("sd", ptr) 326#define __PUT_USER_DW(insn, ptr) __put_user_asm("sd", ptr)
327#endif 327#endif
328 328
329#define __put_user_nocheck(x, ptr, size) \ 329#define __put_user_common(ptr, size) \
330({ \ 330do { \
331 __typeof__(*(ptr)) __pu_val; \
332 int __pu_err = 0; \
333 \
334 __chk_user_ptr(ptr); \
335 __pu_val = (x); \
336 switch (size) { \ 331 switch (size) { \
337 case 1: __put_user_asm("sb", ptr); break; \ 332 case 1: __put_user_asm("sb", ptr); break; \
338 case 2: __put_user_asm("sh", ptr); break; \ 333 case 2: __put_user_asm("sh", ptr); break; \
@@ -340,6 +335,16 @@ do { \
340 case 8: __PUT_USER_DW("sw", ptr); break; \ 335 case 8: __PUT_USER_DW("sw", ptr); break; \
341 default: __put_user_unknown(); break; \ 336 default: __put_user_unknown(); break; \
342 } \ 337 } \
338} while (0)
339
340#define __put_user_nocheck(x, ptr, size) \
341({ \
342 __typeof__(*(ptr)) __pu_val; \
343 int __pu_err = 0; \
344 \
345 __chk_user_ptr(ptr); \
346 __pu_val = (x); \
347 __put_user_common(ptr, size); \
343 __pu_err; \ 348 __pu_err; \
344}) 349})
345 350
@@ -350,15 +355,9 @@ do { \
350 int __pu_err = -EFAULT; \ 355 int __pu_err = -EFAULT; \
351 \ 356 \
352 might_fault(); \ 357 might_fault(); \
353 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) { \ 358 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) \
354 switch (size) { \ 359 __put_user_common(__pu_addr, size); \
355 case 1: __put_user_asm("sb", __pu_addr); break; \ 360 \
356 case 2: __put_user_asm("sh", __pu_addr); break; \
357 case 4: __put_user_asm("sw", __pu_addr); break; \
358 case 8: __PUT_USER_DW("sw", __pu_addr); break; \
359 default: __put_user_unknown(); break; \
360 } \
361 } \
362 __pu_err; \ 361 __pu_err; \
363}) 362})
364 363
@@ -594,19 +593,23 @@ do { \
594#define __PUT_USER_UNALIGNED_DW(ptr) __put_user_unaligned_asm("usd", ptr) 593#define __PUT_USER_UNALIGNED_DW(ptr) __put_user_unaligned_asm("usd", ptr)
595#endif 594#endif
596 595
597#define __put_user_unaligned_nocheck(x,ptr,size) \ 596#define __put_user_unaligned_common(ptr, size) \
598({ \ 597do { \
599 __typeof__(*(ptr)) __pu_val; \
600 int __pu_err = 0; \
601 \
602 __pu_val = (x); \
603 switch (size) { \ 598 switch (size) { \
604 case 1: __put_user_asm("sb", ptr); break; \ 599 case 1: __put_user_asm("sb", ptr); break; \
605 case 2: __put_user_unaligned_asm("ush", ptr); break; \ 600 case 2: __put_user_unaligned_asm("ush", ptr); break; \
606 case 4: __put_user_unaligned_asm("usw", ptr); break; \ 601 case 4: __put_user_unaligned_asm("usw", ptr); break; \
607 case 8: __PUT_USER_UNALIGNED_DW(ptr); break; \ 602 case 8: __PUT_USER_UNALIGNED_DW(ptr); break; \
608 default: __put_user_unaligned_unknown(); break; \ 603 default: __put_user_unaligned_unknown(); break; \
609 } \ 604} while (0)
605
606#define __put_user_unaligned_nocheck(x,ptr,size) \
607({ \
608 __typeof__(*(ptr)) __pu_val; \
609 int __pu_err = 0; \
610 \
611 __pu_val = (x); \
612 __put_user_unaligned_common(ptr, size); \
610 __pu_err; \ 613 __pu_err; \
611}) 614})
612 615
@@ -616,15 +619,9 @@ do { \
616 __typeof__(*(ptr)) __pu_val = (x); \ 619 __typeof__(*(ptr)) __pu_val = (x); \
617 int __pu_err = -EFAULT; \ 620 int __pu_err = -EFAULT; \
618 \ 621 \
619 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) { \ 622 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) \
620 switch (size) { \ 623 __put_user_unaligned_common(__pu_addr, size); \
621 case 1: __put_user_asm("sb", __pu_addr); break; \ 624 \
622 case 2: __put_user_unaligned_asm("ush", __pu_addr); break; \
623 case 4: __put_user_unaligned_asm("usw", __pu_addr); break; \
624 case 8: __PUT_USER_UNALGINED_DW(__pu_addr); break; \
625 default: __put_user_unaligned_unknown(); break; \
626 } \
627 } \
628 __pu_err; \ 625 __pu_err; \
629}) 626})
630 627