Commit 7ef39548 authored by Zong Li's avatar Zong Li Committed by Greentime Hu

nds32: Clean up the coding style

1. Adjust indentation.
2. Unify argument name of each macro.
3. Add space after comma in parameters list.
4. Add space after 'if' keyword.
5. Replace space by tab.
6. Change asm volatile to __asm__ __volatile__
Signed-off-by: default avatarZong Li <zong@andestech.com>
Acked-by: default avatarGreentime Hu <greentime@andestech.com>
Signed-off-by: default avatarGreentime Hu <greentime@andestech.com>
parent 6cce95a6
......@@ -75,46 +75,48 @@ static inline void set_fs(mm_segment_t fs)
* versions are void (ie, don't return a value as such).
*/
#define get_user(x,p) \
#define get_user(x, ptr) \
({ \
long __e = -EFAULT; \
const __typeof__(*(p)) __user *__p = (p); \
if(likely(access_ok(VERIFY_READ, __p, sizeof(*__p)))) { \
const __typeof__(*(ptr)) __user *__p = (ptr); \
if (likely(access_ok(VERIFY_READ, __p, sizeof(*__p)))) { \
__e = __get_user(x, __p); \
} else \
x = 0; \
} else { \
(x) = 0; \
} \
__e; \
})
#define __get_user(x,ptr) \
#define __get_user(x, ptr) \
({ \
long __gu_err = 0; \
__get_user_err((x),(ptr),__gu_err); \
__get_user_err((x), (ptr), __gu_err); \
__gu_err; \
})
#define __get_user_error(x,ptr,err) \
#define __get_user_error(x, ptr, err) \
({ \
__get_user_err((x),(ptr),err); \
(void) 0; \
__get_user_err((x), (ptr), err); \
(void)0; \
})
#define __get_user_err(x,ptr,err) \
#define __get_user_err(x, ptr, err) \
do { \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
unsigned long __gu_val; \
__chk_user_ptr(__gu_addr); \
switch (sizeof(*(__gu_addr))) { \
case 1: \
__get_user_asm("lbi",__gu_val,__gu_addr,err); \
__get_user_asm("lbi", __gu_val, __gu_addr, (err)); \
break; \
case 2: \
__get_user_asm("lhi",__gu_val,__gu_addr,err); \
__get_user_asm("lhi", __gu_val, __gu_addr, (err)); \
break; \
case 4: \
__get_user_asm("lwi",__gu_val,__gu_addr,err); \
__get_user_asm("lwi", __gu_val, __gu_addr, (err)); \
break; \
case 8: \
__get_user_asm_dword(__gu_val,__gu_addr,err); \
__get_user_asm_dword(__gu_val, __gu_addr, (err)); \
break; \
default: \
BUILD_BUG(); \
......@@ -123,8 +125,8 @@ do { \
(x) = (__typeof__(*(__gu_addr)))__gu_val; \
} while (0)
#define __get_user_asm(inst,x,addr,err) \
asm volatile( \
#define __get_user_asm(inst, x, addr, err) \
__asm__ __volatile__ ( \
"1: "inst" %1,[%2]\n" \
"2:\n" \
" .section .fixup,\"ax\"\n" \
......@@ -150,7 +152,7 @@ do { \
#endif
#define __get_user_asm_dword(x, addr, err) \
asm volatile( \
__asm__ __volatile__ ( \
"\n1:\tlwi " __gu_reg_oper0 ",[%2]\n" \
"\n2:\tlwi " __gu_reg_oper1 ",[%2+4]\n" \
"3:\n" \
......@@ -167,45 +169,47 @@ do { \
: "+r"(err), "=&r"(x) \
: "r"(addr), "i"(-EFAULT) \
: "cc")
#define put_user(x,p) \
#define put_user(x, ptr) \
({ \
long __e = -EFAULT; \
__typeof__(*(p)) __user *__p = (p); \
if(likely(access_ok(VERIFY_WRITE, __p, sizeof(*__p)))) { \
__typeof__(*(ptr)) __user *__p = (ptr); \
if (likely(access_ok(VERIFY_WRITE, __p, sizeof(*__p)))) { \
__e = __put_user(x, __p); \
} \
__e; \
})
#define __put_user(x,ptr) \
#define __put_user(x, ptr) \
({ \
long __pu_err = 0; \
__put_user_err((x),(ptr),__pu_err); \
__put_user_err((x), (ptr), __pu_err); \
__pu_err; \
})
#define __put_user_error(x,ptr,err) \
#define __put_user_error(x, ptr, err) \
({ \
__put_user_err((x),(ptr),err); \
(void) 0; \
__put_user_err((x), (ptr), err); \
(void)0; \
})
#define __put_user_err(x,ptr,err) \
#define __put_user_err(x, ptr, err) \
do { \
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
__typeof__(*(__pu_addr)) __pu_val = (x); \
__chk_user_ptr(__pu_addr); \
switch (sizeof(*(__pu_addr))) { \
case 1: \
__put_user_asm("sbi",__pu_val,__pu_addr,err); \
__put_user_asm("sbi", __pu_val, __pu_addr, (err)); \
break; \
case 2: \
__put_user_asm("shi",__pu_val,__pu_addr,err); \
__put_user_asm("shi", __pu_val, __pu_addr, (err)); \
break; \
case 4: \
__put_user_asm("swi",__pu_val,__pu_addr,err); \
__put_user_asm("swi", __pu_val, __pu_addr, (err)); \
break; \
case 8: \
__put_user_asm_dword(__pu_val,__pu_addr,err); \
__put_user_asm_dword(__pu_val, __pu_addr, (err)); \
break; \
default: \
BUILD_BUG(); \
......@@ -213,8 +217,8 @@ do { \
} \
} while (0)
#define __put_user_asm(inst,x,addr,err) \
asm volatile( \
#define __put_user_asm(inst, x, addr, err) \
__asm__ __volatile__ ( \
"1: "inst" %1,[%2]\n" \
"2:\n" \
" .section .fixup,\"ax\"\n" \
......@@ -239,7 +243,7 @@ do { \
#endif
#define __put_user_asm_dword(x, addr, err) \
asm volatile( \
__asm__ __volatile__ ( \
"\n1:\tswi " __pu_reg_oper0 ",[%1]\n" \
"\n2:\tswi " __pu_reg_oper1 ",[%1+4]\n" \
"3:\n" \
......@@ -256,6 +260,7 @@ do { \
: "+r"(err) \
: "r"(addr), "r"(x), "i"(-EFAULT) \
: "cc")
extern unsigned long __arch_clear_user(void __user * addr, unsigned long n);
extern long strncpy_from_user(char *dest, const char __user * src, long count);
extern __must_check long strlen_user(const char __user * str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment