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
...@@ -38,7 +38,7 @@ struct exception_table_entry { ...@@ -38,7 +38,7 @@ struct exception_table_entry {
extern int fixup_exception(struct pt_regs *regs); extern int fixup_exception(struct pt_regs *regs);
#define KERNEL_DS ((mm_segment_t) { ~0UL }) #define KERNEL_DS ((mm_segment_t) { ~0UL })
#define USER_DS ((mm_segment_t) {TASK_SIZE - 1}) #define USER_DS ((mm_segment_t) {TASK_SIZE - 1})
#define get_ds() (KERNEL_DS) #define get_ds() (KERNEL_DS)
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
...@@ -49,11 +49,11 @@ static inline void set_fs(mm_segment_t fs) ...@@ -49,11 +49,11 @@ static inline void set_fs(mm_segment_t fs)
current_thread_info()->addr_limit = fs; current_thread_info()->addr_limit = fs;
} }
#define segment_eq(a, b) ((a) == (b)) #define segment_eq(a, b) ((a) == (b))
#define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size)) #define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size))
#define access_ok(type, addr, size) \ #define access_ok(type, addr, size) \
__range_ok((unsigned long)addr, (unsigned long)size) __range_ok((unsigned long)addr, (unsigned long)size)
/* /*
* Single-value transfer routines. They automatically use the right * Single-value transfer routines. They automatically use the right
...@@ -75,46 +75,48 @@ static inline void set_fs(mm_segment_t fs) ...@@ -75,46 +75,48 @@ static inline void set_fs(mm_segment_t fs)
* versions are void (ie, don't return a value as such). * versions are void (ie, don't return a value as such).
*/ */
#define get_user(x,p) \ #define get_user(x, ptr) \
({ \ ({ \
long __e = -EFAULT; \ long __e = -EFAULT; \
const __typeof__(*(p)) __user *__p = (p); \ const __typeof__(*(ptr)) __user *__p = (ptr); \
if(likely(access_ok(VERIFY_READ, __p, sizeof(*__p)))) { \ if (likely(access_ok(VERIFY_READ, __p, sizeof(*__p)))) { \
__e = __get_user(x, __p); \ __e = __get_user(x, __p); \
} else \ } else { \
x = 0; \ (x) = 0; \
} \
__e; \ __e; \
}) })
#define __get_user(x,ptr) \
#define __get_user(x, ptr) \
({ \ ({ \
long __gu_err = 0; \ long __gu_err = 0; \
__get_user_err((x),(ptr),__gu_err); \ __get_user_err((x), (ptr), __gu_err); \
__gu_err; \ __gu_err; \
}) })
#define __get_user_error(x,ptr,err) \ #define __get_user_error(x, ptr, err) \
({ \ ({ \
__get_user_err((x),(ptr),err); \ __get_user_err((x), (ptr), err); \
(void) 0; \ (void)0; \
}) })
#define __get_user_err(x,ptr,err) \ #define __get_user_err(x, ptr, err) \
do { \ do { \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
unsigned long __gu_val; \ unsigned long __gu_val; \
__chk_user_ptr(__gu_addr); \ __chk_user_ptr(__gu_addr); \
switch (sizeof(*(__gu_addr))) { \ switch (sizeof(*(__gu_addr))) { \
case 1: \ case 1: \
__get_user_asm("lbi",__gu_val,__gu_addr,err); \ __get_user_asm("lbi", __gu_val, __gu_addr, (err)); \
break; \ break; \
case 2: \ case 2: \
__get_user_asm("lhi",__gu_val,__gu_addr,err); \ __get_user_asm("lhi", __gu_val, __gu_addr, (err)); \
break; \ break; \
case 4: \ case 4: \
__get_user_asm("lwi",__gu_val,__gu_addr,err); \ __get_user_asm("lwi", __gu_val, __gu_addr, (err)); \
break; \ break; \
case 8: \ case 8: \
__get_user_asm_dword(__gu_val,__gu_addr,err); \ __get_user_asm_dword(__gu_val, __gu_addr, (err)); \
break; \ break; \
default: \ default: \
BUILD_BUG(); \ BUILD_BUG(); \
...@@ -123,23 +125,23 @@ do { \ ...@@ -123,23 +125,23 @@ do { \
(x) = (__typeof__(*(__gu_addr)))__gu_val; \ (x) = (__typeof__(*(__gu_addr)))__gu_val; \
} while (0) } while (0)
#define __get_user_asm(inst,x,addr,err) \ #define __get_user_asm(inst, x, addr, err) \
asm volatile( \ __asm__ __volatile__ ( \
"1: "inst" %1,[%2]\n" \ "1: "inst" %1,[%2]\n" \
"2:\n" \ "2:\n" \
" .section .fixup,\"ax\"\n" \ " .section .fixup,\"ax\"\n" \
" .align 2\n" \ " .align 2\n" \
"3: move %0, %3\n" \ "3: move %0, %3\n" \
" move %1, #0\n" \ " move %1, #0\n" \
" b 2b\n" \ " b 2b\n" \
" .previous\n" \ " .previous\n" \
" .section __ex_table,\"a\"\n" \ " .section __ex_table,\"a\"\n" \
" .align 3\n" \ " .align 3\n" \
" .long 1b, 3b\n" \ " .long 1b, 3b\n" \
" .previous" \ " .previous" \
: "+r" (err), "=&r" (x) \ : "+r" (err), "=&r" (x) \
: "r" (addr), "i" (-EFAULT) \ : "r" (addr), "i" (-EFAULT) \
: "cc") : "cc")
#ifdef __NDS32_EB__ #ifdef __NDS32_EB__
#define __gu_reg_oper0 "%H1" #define __gu_reg_oper0 "%H1"
...@@ -150,62 +152,64 @@ do { \ ...@@ -150,62 +152,64 @@ do { \
#endif #endif
#define __get_user_asm_dword(x, addr, err) \ #define __get_user_asm_dword(x, addr, err) \
asm volatile( \ __asm__ __volatile__ ( \
"\n1:\tlwi " __gu_reg_oper0 ",[%2]\n" \ "\n1:\tlwi " __gu_reg_oper0 ",[%2]\n" \
"\n2:\tlwi " __gu_reg_oper1 ",[%2+4]\n" \ "\n2:\tlwi " __gu_reg_oper1 ",[%2+4]\n" \
"3:\n" \ "3:\n" \
" .section .fixup,\"ax\"\n" \ " .section .fixup,\"ax\"\n" \
" .align 2\n" \ " .align 2\n" \
"4: move %0, %3\n" \ "4: move %0, %3\n" \
" b 3b\n" \ " b 3b\n" \
" .previous\n" \ " .previous\n" \
" .section __ex_table,\"a\"\n" \ " .section __ex_table,\"a\"\n" \
" .align 3\n" \ " .align 3\n" \
" .long 1b, 4b\n" \ " .long 1b, 4b\n" \
" .long 2b, 4b\n" \ " .long 2b, 4b\n" \
" .previous" \ " .previous" \
: "+r"(err), "=&r"(x) \ : "+r"(err), "=&r"(x) \
: "r"(addr), "i"(-EFAULT) \ : "r"(addr), "i"(-EFAULT) \
: "cc") : "cc")
#define put_user(x,p) \
#define put_user(x, ptr) \
({ \ ({ \
long __e = -EFAULT; \ long __e = -EFAULT; \
__typeof__(*(p)) __user *__p = (p); \ __typeof__(*(ptr)) __user *__p = (ptr); \
if(likely(access_ok(VERIFY_WRITE, __p, sizeof(*__p)))) { \ if (likely(access_ok(VERIFY_WRITE, __p, sizeof(*__p)))) { \
__e = __put_user(x, __p); \ __e = __put_user(x, __p); \
} \ } \
__e; \ __e; \
}) })
#define __put_user(x,ptr) \
#define __put_user(x, ptr) \
({ \ ({ \
long __pu_err = 0; \ long __pu_err = 0; \
__put_user_err((x),(ptr),__pu_err); \ __put_user_err((x), (ptr), __pu_err); \
__pu_err; \ __pu_err; \
}) })
#define __put_user_error(x,ptr,err) \ #define __put_user_error(x, ptr, err) \
({ \ ({ \
__put_user_err((x),(ptr),err); \ __put_user_err((x), (ptr), err); \
(void) 0; \ (void)0; \
}) })
#define __put_user_err(x,ptr,err) \ #define __put_user_err(x, ptr, err) \
do { \ do { \
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \ __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
__typeof__(*(__pu_addr)) __pu_val = (x); \ __typeof__(*(__pu_addr)) __pu_val = (x); \
__chk_user_ptr(__pu_addr); \ __chk_user_ptr(__pu_addr); \
switch (sizeof(*(__pu_addr))) { \ switch (sizeof(*(__pu_addr))) { \
case 1: \ case 1: \
__put_user_asm("sbi",__pu_val,__pu_addr,err); \ __put_user_asm("sbi", __pu_val, __pu_addr, (err)); \
break; \ break; \
case 2: \ case 2: \
__put_user_asm("shi",__pu_val,__pu_addr,err); \ __put_user_asm("shi", __pu_val, __pu_addr, (err)); \
break; \ break; \
case 4: \ case 4: \
__put_user_asm("swi",__pu_val,__pu_addr,err); \ __put_user_asm("swi", __pu_val, __pu_addr, (err)); \
break; \ break; \
case 8: \ case 8: \
__put_user_asm_dword(__pu_val,__pu_addr,err); \ __put_user_asm_dword(__pu_val, __pu_addr, (err)); \
break; \ break; \
default: \ default: \
BUILD_BUG(); \ BUILD_BUG(); \
...@@ -213,22 +217,22 @@ do { \ ...@@ -213,22 +217,22 @@ do { \
} \ } \
} while (0) } while (0)
#define __put_user_asm(inst,x,addr,err) \ #define __put_user_asm(inst, x, addr, err) \
asm volatile( \ __asm__ __volatile__ ( \
"1: "inst" %1,[%2]\n" \ "1: "inst" %1,[%2]\n" \
"2:\n" \ "2:\n" \
" .section .fixup,\"ax\"\n" \ " .section .fixup,\"ax\"\n" \
" .align 2\n" \ " .align 2\n" \
"3: move %0, %3\n" \ "3: move %0, %3\n" \
" b 2b\n" \ " b 2b\n" \
" .previous\n" \ " .previous\n" \
" .section __ex_table,\"a\"\n" \ " .section __ex_table,\"a\"\n" \
" .align 3\n" \ " .align 3\n" \
" .long 1b, 3b\n" \ " .long 1b, 3b\n" \
" .previous" \ " .previous" \
: "+r" (err) \ : "+r" (err) \
: "r" (x), "r" (addr), "i" (-EFAULT) \ : "r" (x), "r" (addr), "i" (-EFAULT) \
: "cc") : "cc")
#ifdef __NDS32_EB__ #ifdef __NDS32_EB__
#define __pu_reg_oper0 "%H2" #define __pu_reg_oper0 "%H2"
...@@ -239,23 +243,24 @@ do { \ ...@@ -239,23 +243,24 @@ do { \
#endif #endif
#define __put_user_asm_dword(x, addr, err) \ #define __put_user_asm_dword(x, addr, err) \
asm volatile( \ __asm__ __volatile__ ( \
"\n1:\tswi " __pu_reg_oper0 ",[%1]\n" \ "\n1:\tswi " __pu_reg_oper0 ",[%1]\n" \
"\n2:\tswi " __pu_reg_oper1 ",[%1+4]\n" \ "\n2:\tswi " __pu_reg_oper1 ",[%1+4]\n" \
"3:\n" \ "3:\n" \
" .section .fixup,\"ax\"\n" \ " .section .fixup,\"ax\"\n" \
" .align 2\n" \ " .align 2\n" \
"4: move %0, %3\n" \ "4: move %0, %3\n" \
" b 3b\n" \ " b 3b\n" \
" .previous\n" \ " .previous\n" \
" .section __ex_table,\"a\"\n" \ " .section __ex_table,\"a\"\n" \
" .align 3\n" \ " .align 3\n" \
" .long 1b, 4b\n" \ " .long 1b, 4b\n" \
" .long 2b, 4b\n" \ " .long 2b, 4b\n" \
" .previous" \ " .previous" \
: "+r"(err) \ : "+r"(err) \
: "r"(addr), "r"(x), "i"(-EFAULT) \ : "r"(addr), "r"(x), "i"(-EFAULT) \
: "cc") : "cc")
extern unsigned long __arch_clear_user(void __user * addr, unsigned long n); 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 long strncpy_from_user(char *dest, const char __user * src, long count);
extern __must_check long strlen_user(const char __user * str); 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