[PATCH -next v2 1/2] riscv: uaccess: rename __get/put_user_nocheck to __get/put_mem_nocheck
Tong Tiangen
tongtiangen at huawei.com
Sun Aug 14 20:20:24 PDT 2022
Current, The helpers __get/put_user_nocheck() is used by get/put_user() and
__get/put_kernel_nofault(), which is not always uaccess, so the name with
*user* is not appropriate.
Also rename xxx_user_xxx to xxx_mem_xx on the call path of
__get/put_user_nocheck()
Only refactor code without any functional changes.
Signed-off-by: Tong Tiangen <tongtiangen at huawei.com>
---
arch/riscv/include/asm/uaccess.h | 48 ++++++++++++++++----------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
index 855450bed9f5..1370da055b44 100644
--- a/arch/riscv/include/asm/uaccess.h
+++ b/arch/riscv/include/asm/uaccess.h
@@ -50,7 +50,7 @@
* call.
*/
-#define __get_user_asm(insn, x, ptr, err) \
+#define __get_mem_asm(insn, x, ptr, err) \
do { \
__typeof__(x) __x; \
__asm__ __volatile__ ( \
@@ -64,12 +64,12 @@ do { \
} while (0)
#ifdef CONFIG_64BIT
-#define __get_user_8(x, ptr, err) \
- __get_user_asm("ld", x, ptr, err)
+#define __get_mem_8(x, ptr, err) \
+ __get_mem_asm("ld", x, ptr, err)
#else /* !CONFIG_64BIT */
-#define __get_user_8(x, ptr, err) \
+#define __get_mem_8(x, ptr, err) \
do { \
- u32 __user *__ptr = (u32 __user *)(ptr); \
+ u32 *__ptr = (u32 *)(ptr); \
u32 __lo, __hi; \
__asm__ __volatile__ ( \
"1:\n" \
@@ -88,20 +88,20 @@ do { \
} while (0)
#endif /* CONFIG_64BIT */
-#define __get_user_nocheck(x, __gu_ptr, __gu_err) \
+#define __get_mem_nocheck(x, __gu_ptr, __gu_err) \
do { \
switch (sizeof(*__gu_ptr)) { \
case 1: \
- __get_user_asm("lb", (x), __gu_ptr, __gu_err); \
+ __get_mem_asm("lb", (x), __gu_ptr, __gu_err); \
break; \
case 2: \
- __get_user_asm("lh", (x), __gu_ptr, __gu_err); \
+ __get_mem_asm("lh", (x), __gu_ptr, __gu_err); \
break; \
case 4: \
- __get_user_asm("lw", (x), __gu_ptr, __gu_err); \
+ __get_mem_asm("lw", (x), __gu_ptr, __gu_err); \
break; \
case 8: \
- __get_user_8((x), __gu_ptr, __gu_err); \
+ __get_mem_8((x), __gu_ptr, __gu_err); \
break; \
default: \
BUILD_BUG(); \
@@ -136,7 +136,7 @@ do { \
__chk_user_ptr(__gu_ptr); \
\
__enable_user_access(); \
- __get_user_nocheck(x, __gu_ptr, __gu_err); \
+ __get_mem_nocheck(x, __gu_ptr, __gu_err); \
__disable_user_access(); \
\
__gu_err; \
@@ -168,7 +168,7 @@ do { \
((x) = 0, -EFAULT); \
})
-#define __put_user_asm(insn, x, ptr, err) \
+#define __put_mem_asm(insn, x, ptr, err) \
do { \
__typeof__(*(ptr)) __x = x; \
__asm__ __volatile__ ( \
@@ -181,12 +181,12 @@ do { \
} while (0)
#ifdef CONFIG_64BIT
-#define __put_user_8(x, ptr, err) \
- __put_user_asm("sd", x, ptr, err)
+#define __put_mem_8(x, ptr, err) \
+ __put_mem_asm("sd", x, ptr, err)
#else /* !CONFIG_64BIT */
-#define __put_user_8(x, ptr, err) \
+#define __put_mem_8(x, ptr, err) \
do { \
- u32 __user *__ptr = (u32 __user *)(ptr); \
+ u32 *__ptr = (u32 *)(ptr); \
u64 __x = (__typeof__((x)-(x)))(x); \
__asm__ __volatile__ ( \
"1:\n" \
@@ -203,20 +203,20 @@ do { \
} while (0)
#endif /* CONFIG_64BIT */
-#define __put_user_nocheck(x, __gu_ptr, __pu_err) \
+#define __put_mem_nocheck(x, __gu_ptr, __pu_err) \
do { \
switch (sizeof(*__gu_ptr)) { \
case 1: \
- __put_user_asm("sb", (x), __gu_ptr, __pu_err); \
+ __put_mem_asm("sb", (x), __gu_ptr, __pu_err); \
break; \
case 2: \
- __put_user_asm("sh", (x), __gu_ptr, __pu_err); \
+ __put_mem_asm("sh", (x), __gu_ptr, __pu_err); \
break; \
case 4: \
- __put_user_asm("sw", (x), __gu_ptr, __pu_err); \
+ __put_mem_asm("sw", (x), __gu_ptr, __pu_err); \
break; \
case 8: \
- __put_user_8((x), __gu_ptr, __pu_err); \
+ __put_mem_8((x), __gu_ptr, __pu_err); \
break; \
default: \
BUILD_BUG(); \
@@ -253,7 +253,7 @@ do { \
__chk_user_ptr(__gu_ptr); \
\
__enable_user_access(); \
- __put_user_nocheck(__val, __gu_ptr, __pu_err); \
+ __put_mem_nocheck(__val, __gu_ptr, __pu_err); \
__disable_user_access(); \
\
__pu_err; \
@@ -321,7 +321,7 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n)
do { \
long __kr_err; \
\
- __get_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \
+ __get_mem_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \
if (unlikely(__kr_err)) \
goto err_label; \
} while (0)
@@ -330,7 +330,7 @@ do { \
do { \
long __kr_err; \
\
- __put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err); \
+ __put_mem_nocheck(*((type *)(src)), (type *)(dst), __kr_err); \
if (unlikely(__kr_err)) \
goto err_label; \
} while (0)
--
2.25.1
More information about the linux-riscv
mailing list