Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARC: refactor atomic inline asm operands with symbolic names

This reduces the diff in forth-coming patches and also helps understand
better the incremental changes to inline asm.

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

+17 -15
+17 -15
arch/arc/include/asm/atomic.h
··· 26 26 #define ATOMIC_OP(op, c_op, asm_op) \ 27 27 static inline void atomic_##op(int i, atomic_t *v) \ 28 28 { \ 29 - unsigned int temp; \ 29 + unsigned int val; \ 30 30 \ 31 31 __asm__ __volatile__( \ 32 - "1: llock %0, [%1] \n" \ 33 - " " #asm_op " %0, %0, %2 \n" \ 34 - " scond %0, [%1] \n" \ 35 - " bnz 1b \n" \ 36 - : "=&r"(temp) /* Early clobber, to prevent reg reuse */ \ 37 - : "r"(&v->counter), "ir"(i) \ 32 + "1: llock %[val], [%[ctr]] \n" \ 33 + " " #asm_op " %[val], %[val], %[i] \n" \ 34 + " scond %[val], [%[ctr]] \n" \ 35 + " bnz 1b \n" \ 36 + : [val] "=&r" (val) /* Early clobber to prevent reg reuse */ \ 37 + : [ctr] "r" (&v->counter), /* Not "m": llock only supports reg direct addr mode */ \ 38 + [i] "ir" (i) \ 38 39 : "cc"); \ 39 40 } \ 40 41 41 42 #define ATOMIC_OP_RETURN(op, c_op, asm_op) \ 42 43 static inline int atomic_##op##_return(int i, atomic_t *v) \ 43 44 { \ 44 - unsigned int temp; \ 45 + unsigned int val; \ 45 46 \ 46 47 /* \ 47 48 * Explicit full memory barrier needed before/after as \ ··· 51 50 smp_mb(); \ 52 51 \ 53 52 __asm__ __volatile__( \ 54 - "1: llock %0, [%1] \n" \ 55 - " " #asm_op " %0, %0, %2 \n" \ 56 - " scond %0, [%1] \n" \ 57 - " bnz 1b \n" \ 58 - : "=&r"(temp) \ 59 - : "r"(&v->counter), "ir"(i) \ 53 + "1: llock %[val], [%[ctr]] \n" \ 54 + " " #asm_op " %[val], %[val], %[i] \n" \ 55 + " scond %[val], [%[ctr]] \n" \ 56 + " bnz 1b \n" \ 57 + : [val] "=&r" (val) \ 58 + : [ctr] "r" (&v->counter), \ 59 + [i] "ir" (i) \ 60 60 : "cc"); \ 61 61 \ 62 62 smp_mb(); \ 63 63 \ 64 - return temp; \ 64 + return val; \ 65 65 } 66 66 67 67 #else /* !CONFIG_ARC_HAS_LLSC */