aboutsummaryrefslogtreecommitdiffstats
path: root/arch/frv/include/asm/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/frv/include/asm/atomic.h')
-rw-r--r--arch/frv/include/asm/atomic.h57
1 files changed, 1 insertions, 56 deletions
diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
index 0d8a7d661740..b86329d0e316 100644
--- a/arch/frv/include/asm/atomic.h
+++ b/arch/frv/include/asm/atomic.h
@@ -16,7 +16,7 @@
16 16
17#include <linux/types.h> 17#include <linux/types.h>
18#include <asm/spr-regs.h> 18#include <asm/spr-regs.h>
19#include <asm/system.h> 19#include <asm/cmpxchg.h>
20 20
21#ifdef CONFIG_SMP 21#ifdef CONFIG_SMP
22#error not SMP safe 22#error not SMP safe
@@ -181,61 +181,6 @@ static inline void atomic64_dec(atomic64_t *v)
181#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0) 181#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
182#define atomic64_inc_and_test(v) (atomic64_inc_return((v)) == 0) 182#define atomic64_inc_and_test(v) (atomic64_inc_return((v)) == 0)
183 183
184/*****************************************************************************/
185/*
186 * exchange value with memory
187 */
188extern uint64_t __xchg_64(uint64_t i, volatile void *v);
189
190#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
191
192#define xchg(ptr, x) \
193({ \
194 __typeof__(ptr) __xg_ptr = (ptr); \
195 __typeof__(*(ptr)) __xg_orig; \
196 \
197 switch (sizeof(__xg_orig)) { \
198 case 4: \
199 asm volatile( \
200 "swap%I0 %M0,%1" \
201 : "+m"(*__xg_ptr), "=r"(__xg_orig) \
202 : "1"(x) \
203 : "memory" \
204 ); \
205 break; \
206 \
207 default: \
208 __xg_orig = (__typeof__(__xg_orig))0; \
209 asm volatile("break"); \
210 break; \
211 } \
212 \
213 __xg_orig; \
214})
215
216#else
217
218extern uint32_t __xchg_32(uint32_t i, volatile void *v);
219
220#define xchg(ptr, x) \
221({ \
222 __typeof__(ptr) __xg_ptr = (ptr); \
223 __typeof__(*(ptr)) __xg_orig; \
224 \
225 switch (sizeof(__xg_orig)) { \
226 case 4: __xg_orig = (__typeof__(*(ptr))) __xchg_32((uint32_t) x, __xg_ptr); break; \
227 default: \
228 __xg_orig = (__typeof__(__xg_orig))0; \
229 asm volatile("break"); \
230 break; \
231 } \
232 __xg_orig; \
233})
234
235#endif
236
237#define tas(ptr) (xchg((ptr), 1))
238
239#define atomic_cmpxchg(v, old, new) (cmpxchg(&(v)->counter, old, new)) 184#define atomic_cmpxchg(v, old, new) (cmpxchg(&(v)->counter, old, new))
240#define atomic_xchg(v, new) (xchg(&(v)->counter, new)) 185#define atomic_xchg(v, new) (xchg(&(v)->counter, new))
241#define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter)) 186#define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))