diff options
author | Rabin Vincent <rabin@rab.in> | 2015-02-19 12:56:17 -0500 |
---|---|---|
committer | Jesper Nilsson <jespern@axis.com> | 2015-03-25 05:57:07 -0400 |
commit | f87a2f58e34857304b8a2c284d02360210186dd0 (patch) | |
tree | a4f2059c1b51a91cc8c3e42f1c39b1344dac0a4c /arch | |
parent | e7db8a3c96970d847da5611e78b6bde998f13da8 (diff) |
CRIS: use generic cmpxchg.h
CRIS can use asm-generic's cmpxchg.h
Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Jesper Nilsson <jespern@axis.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/cris/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/cris/include/asm/cmpxchg.h | 51 |
2 files changed, 1 insertions, 51 deletions
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild index 2f2787e15b64..e189931d7992 100644 --- a/arch/cris/include/asm/Kbuild +++ b/arch/cris/include/asm/Kbuild | |||
@@ -1,6 +1,7 @@ | |||
1 | generic-y += atomic.h | 1 | generic-y += atomic.h |
2 | generic-y += barrier.h | 2 | generic-y += barrier.h |
3 | generic-y += clkdev.h | 3 | generic-y += clkdev.h |
4 | generic-y += cmpxchg.h | ||
4 | generic-y += cputime.h | 5 | generic-y += cputime.h |
5 | generic-y += exec.h | 6 | generic-y += exec.h |
6 | generic-y += irq_work.h | 7 | generic-y += irq_work.h |
diff --git a/arch/cris/include/asm/cmpxchg.h b/arch/cris/include/asm/cmpxchg.h deleted file mode 100644 index deb9048a6003..000000000000 --- a/arch/cris/include/asm/cmpxchg.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | #ifndef __ASM_CRIS_CMPXCHG__ | ||
2 | #define __ASM_CRIS_CMPXCHG__ | ||
3 | |||
4 | #include <linux/irqflags.h> | ||
5 | |||
6 | static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size) | ||
7 | { | ||
8 | /* since Etrax doesn't have any atomic xchg instructions, we need to disable | ||
9 | irq's (if enabled) and do it with move.d's */ | ||
10 | unsigned long flags,temp; | ||
11 | local_irq_save(flags); /* save flags, including irq enable bit and shut off irqs */ | ||
12 | switch (size) { | ||
13 | case 1: | ||
14 | *((unsigned char *)&temp) = x; | ||
15 | x = *(unsigned char *)ptr; | ||
16 | *(unsigned char *)ptr = *((unsigned char *)&temp); | ||
17 | break; | ||
18 | case 2: | ||
19 | *((unsigned short *)&temp) = x; | ||
20 | x = *(unsigned short *)ptr; | ||
21 | *(unsigned short *)ptr = *((unsigned short *)&temp); | ||
22 | break; | ||
23 | case 4: | ||
24 | temp = x; | ||
25 | x = *(unsigned long *)ptr; | ||
26 | *(unsigned long *)ptr = temp; | ||
27 | break; | ||
28 | } | ||
29 | local_irq_restore(flags); /* restore irq enable bit */ | ||
30 | return x; | ||
31 | } | ||
32 | |||
33 | #define xchg(ptr,x) \ | ||
34 | ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) | ||
35 | |||
36 | #define tas(ptr) (xchg((ptr),1)) | ||
37 | |||
38 | #include <asm-generic/cmpxchg-local.h> | ||
39 | |||
40 | /* | ||
41 | * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make | ||
42 | * them available. | ||
43 | */ | ||
44 | #define cmpxchg_local(ptr, o, n) \ | ||
45 | ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ | ||
46 | (unsigned long)(n), sizeof(*(ptr)))) | ||
47 | #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) | ||
48 | |||
49 | #include <asm-generic/cmpxchg.h> | ||
50 | |||
51 | #endif /* __ASM_CRIS_CMPXCHG__ */ | ||