提交 50f853e3 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

locking,arch,hexagon: Fold atomic_ops

OK, no LoC saved in this case because the !return variants were
defined in terms of the return ops. Still do it because this also
prepares for easy addition of new ops.
Signed-off-by: NPeter Zijlstra <peterz@infradead.org>
Acked-by: NRichard Kuo <rkuo@codeaurora.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: linux-hexagon@vger.kernel.org
Link: http://lkml.kernel.org/r/20140508135852.171567636@infradead.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 7179e30e
...@@ -94,41 +94,47 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new) ...@@ -94,41 +94,47 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
return __oldval; return __oldval;
} }
static inline int atomic_add_return(int i, atomic_t *v) #define ATOMIC_OP(op) \
{ static inline void atomic_##op(int i, atomic_t *v) \
int output; { \
int output; \
__asm__ __volatile__ ( \
"1: %0 = memw_locked(%1);\n" __asm__ __volatile__ ( \
" %0 = add(%0,%2);\n" "1: %0 = memw_locked(%1);\n" \
" memw_locked(%1,P3)=%0;\n" " %0 = "#op "(%0,%2);\n" \
" if !P3 jump 1b;\n" " memw_locked(%1,P3)=%0;\n" \
: "=&r" (output) " if !P3 jump 1b;\n" \
: "r" (&v->counter), "r" (i) : "=&r" (output) \
: "memory", "p3" : "r" (&v->counter), "r" (i) \
); : "memory", "p3" \
return output; ); \
} \
#define ATOMIC_OP_RETURN(op) \
static inline int atomic_##op##_return(int i, atomic_t *v) \
{ \
int output; \
\
__asm__ __volatile__ ( \
"1: %0 = memw_locked(%1);\n" \
" %0 = "#op "(%0,%2);\n" \
" memw_locked(%1,P3)=%0;\n" \
" if !P3 jump 1b;\n" \
: "=&r" (output) \
: "r" (&v->counter), "r" (i) \
: "memory", "p3" \
); \
return output; \
} }
#define atomic_add(i, v) atomic_add_return(i, (v)) #define ATOMIC_OPS(op) ATOMIC_OP(op) ATOMIC_OP_RETURN(op)
static inline int atomic_sub_return(int i, atomic_t *v) ATOMIC_OPS(add)
{ ATOMIC_OPS(sub)
int output;
__asm__ __volatile__ (
"1: %0 = memw_locked(%1);\n"
" %0 = sub(%0,%2);\n"
" memw_locked(%1,P3)=%0\n"
" if !P3 jump 1b;\n"
: "=&r" (output)
: "r" (&v->counter), "r" (i)
: "memory", "p3"
);
return output;
}
#define atomic_sub(i, v) atomic_sub_return(i, (v)) #undef ATOMIC_OPS
#undef ATOMIC_OP_RETURN
#undef ATOMIC_OP
/** /**
* __atomic_add_unless - add unless the number is a given value * __atomic_add_unless - add unless the number is a given value
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部