summaryrefslogtreecommitdiffstats
path: root/arch/nios2
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2015-09-30 10:08:00 -0400
committerLey Foon Tan <lftan@altera.com>2015-11-08 21:33:30 -0500
commit713e9b802e21e762f31336da72bcfc32e1ab65ac (patch)
tree596930c090db40d4410445d288913c782686e117 /arch/nios2
parent4db2196d0c0de110779b1767d956995efefdb915 (diff)
nios2: Switch to generic __xchg()
The generic __xchg() implementation present in asm-generic/cmpxchg.h is correct on nios2 and even generates the same code. Switch to this generic implementation to trim down the amount of ad-hoc copies of the code. Signed-off-by: Marek Vasut <marex@denx.de> Acked-by: Ley Foon Tan <lftan@altera.com>
Diffstat (limited to 'arch/nios2')
-rw-r--r--arch/nios2/include/asm/cmpxchg.h47
1 files changed, 0 insertions, 47 deletions
diff --git a/arch/nios2/include/asm/cmpxchg.h b/arch/nios2/include/asm/cmpxchg.h
index 85938711542d..a7978f14d157 100644
--- a/arch/nios2/include/asm/cmpxchg.h
+++ b/arch/nios2/include/asm/cmpxchg.h
@@ -9,53 +9,6 @@
9#ifndef _ASM_NIOS2_CMPXCHG_H 9#ifndef _ASM_NIOS2_CMPXCHG_H
10#define _ASM_NIOS2_CMPXCHG_H 10#define _ASM_NIOS2_CMPXCHG_H
11 11
12#include <linux/irqflags.h>
13
14#define xchg(ptr, x) \
15 ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
16
17struct __xchg_dummy { unsigned long a[100]; };
18#define __xg(x) ((volatile struct __xchg_dummy *)(x))
19
20static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
21 int size)
22{
23 unsigned long tmp, flags;
24
25 local_irq_save(flags);
26
27 switch (size) {
28 case 1:
29 __asm__ __volatile__(
30 "ldb %0, %2\n"
31 "stb %1, %2\n"
32 : "=&r" (tmp)
33 : "r" (x), "m" (*__xg(ptr))
34 : "memory");
35 break;
36 case 2:
37 __asm__ __volatile__(
38 "ldh %0, %2\n"
39 "sth %1, %2\n"
40 : "=&r" (tmp)
41 : "r" (x), "m" (*__xg(ptr))
42 : "memory");
43 break;
44 case 4:
45 __asm__ __volatile__(
46 "ldw %0, %2\n"
47 "stw %1, %2\n"
48 : "=&r" (tmp)
49 : "r" (x), "m" (*__xg(ptr))
50 : "memory");
51 break;
52 }
53
54 local_irq_restore(flags);
55 return tmp;
56}
57
58#include <asm-generic/cmpxchg.h> 12#include <asm-generic/cmpxchg.h>
59#include <asm-generic/cmpxchg-local.h>
60 13
61#endif /* _ASM_NIOS2_CMPXCHG_H */ 14#endif /* _ASM_NIOS2_CMPXCHG_H */