aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/include
diff options
context:
space:
mode:
authorRabin Vincent <rabin@rab.in>2015-02-19 11:54:35 -0500
committerJesper Nilsson <jespern@axis.com>2015-03-25 05:57:03 -0400
commite7db8a3c96970d847da5611e78b6bde998f13da8 (patch)
tree9c4543653b8c197427f55a5fde0b8fe83b0175f6 /arch/cris/include
parentf64751118b07579c7ebb7935b6fd8cc8e2c3291a (diff)
CRIS: use generic atomic.h
CRIS can use asm-generic's atomic.h. Signed-off-by: Rabin Vincent <rabin@rab.in> Signed-off-by: Jesper Nilsson <jespern@axis.com>
Diffstat (limited to 'arch/cris/include')
-rw-r--r--arch/cris/include/arch-v10/arch/atomic.h7
-rw-r--r--arch/cris/include/arch-v32/arch/atomic.h8
-rw-r--r--arch/cris/include/asm/Kbuild2
-rw-r--r--arch/cris/include/asm/atomic.h149
4 files changed, 1 insertions, 165 deletions
diff --git a/arch/cris/include/arch-v10/arch/atomic.h b/arch/cris/include/arch-v10/arch/atomic.h
deleted file mode 100644
index 6ef5e7d09024..000000000000
--- a/arch/cris/include/arch-v10/arch/atomic.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_CRIS_ARCH_ATOMIC__
2#define __ASM_CRIS_ARCH_ATOMIC__
3
4#define cris_atomic_save(addr, flags) local_irq_save(flags);
5#define cris_atomic_restore(addr, flags) local_irq_restore(flags);
6
7#endif
diff --git a/arch/cris/include/arch-v32/arch/atomic.h b/arch/cris/include/arch-v32/arch/atomic.h
deleted file mode 100644
index 9c7d105b894b..000000000000
--- a/arch/cris/include/arch-v32/arch/atomic.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_CRIS_ARCH_ATOMIC__
2#define __ASM_CRIS_ARCH_ATOMIC__
3
4#define cris_atomic_save(addr, flags) local_irq_save(flags);
5#define cris_atomic_restore(addr, flags) local_irq_restore(flags);
6
7#endif
8
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index 889f2de050a3..2f2787e15b64 100644
--- a/arch/cris/include/asm/Kbuild
+++ b/arch/cris/include/asm/Kbuild
@@ -1,4 +1,4 @@
1 1generic-y += atomic.h
2generic-y += barrier.h 2generic-y += barrier.h
3generic-y += clkdev.h 3generic-y += clkdev.h
4generic-y += cputime.h 4generic-y += cputime.h
diff --git a/arch/cris/include/asm/atomic.h b/arch/cris/include/asm/atomic.h
deleted file mode 100644
index 279766a70664..000000000000
--- a/arch/cris/include/asm/atomic.h
+++ /dev/null
@@ -1,149 +0,0 @@
1/* $Id: atomic.h,v 1.3 2001/07/25 16:15:19 bjornw Exp $ */
2
3#ifndef __ASM_CRIS_ATOMIC__
4#define __ASM_CRIS_ATOMIC__
5
6#include <linux/compiler.h>
7#include <linux/types.h>
8#include <asm/cmpxchg.h>
9#include <arch/atomic.h>
10#include <arch/system.h>
11#include <asm/barrier.h>
12
13/*
14 * Atomic operations that C can't guarantee us. Useful for
15 * resource counting etc..
16 */
17
18#define ATOMIC_INIT(i) { (i) }
19
20#define atomic_read(v) ACCESS_ONCE((v)->counter)
21#define atomic_set(v,i) (((v)->counter) = (i))
22
23/* These should be written in asm but we do it in C for now. */
24
25#define ATOMIC_OP(op, c_op) \
26static inline void atomic_##op(int i, volatile atomic_t *v) \
27{ \
28 unsigned long flags; \
29 cris_atomic_save(v, flags); \
30 v->counter c_op i; \
31 cris_atomic_restore(v, flags); \
32} \
33
34#define ATOMIC_OP_RETURN(op, c_op) \
35static inline int atomic_##op##_return(int i, volatile atomic_t *v) \
36{ \
37 unsigned long flags; \
38 int retval; \
39 cris_atomic_save(v, flags); \
40 retval = (v->counter c_op i); \
41 cris_atomic_restore(v, flags); \
42 return retval; \
43}
44
45#define ATOMIC_OPS(op, c_op) ATOMIC_OP(op, c_op) ATOMIC_OP_RETURN(op, c_op)
46
47ATOMIC_OPS(add, +=)
48ATOMIC_OPS(sub, -=)
49
50#undef ATOMIC_OPS
51#undef ATOMIC_OP_RETURN
52#undef ATOMIC_OP
53
54#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
55
56static inline int atomic_sub_and_test(int i, volatile atomic_t *v)
57{
58 int retval;
59 unsigned long flags;
60 cris_atomic_save(v, flags);
61 retval = (v->counter -= i) == 0;
62 cris_atomic_restore(v, flags);
63 return retval;
64}
65
66static inline void atomic_inc(volatile atomic_t *v)
67{
68 unsigned long flags;
69 cris_atomic_save(v, flags);
70 (v->counter)++;
71 cris_atomic_restore(v, flags);
72}
73
74static inline void atomic_dec(volatile atomic_t *v)
75{
76 unsigned long flags;
77 cris_atomic_save(v, flags);
78 (v->counter)--;
79 cris_atomic_restore(v, flags);
80}
81
82static inline int atomic_inc_return(volatile atomic_t *v)
83{
84 unsigned long flags;
85 int retval;
86 cris_atomic_save(v, flags);
87 retval = ++(v->counter);
88 cris_atomic_restore(v, flags);
89 return retval;
90}
91
92static inline int atomic_dec_return(volatile atomic_t *v)
93{
94 unsigned long flags;
95 int retval;
96 cris_atomic_save(v, flags);
97 retval = --(v->counter);
98 cris_atomic_restore(v, flags);
99 return retval;
100}
101static inline int atomic_dec_and_test(volatile atomic_t *v)
102{
103 int retval;
104 unsigned long flags;
105 cris_atomic_save(v, flags);
106 retval = --(v->counter) == 0;
107 cris_atomic_restore(v, flags);
108 return retval;
109}
110
111static inline int atomic_inc_and_test(volatile atomic_t *v)
112{
113 int retval;
114 unsigned long flags;
115 cris_atomic_save(v, flags);
116 retval = ++(v->counter) == 0;
117 cris_atomic_restore(v, flags);
118 return retval;
119}
120
121static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
122{
123 int ret;
124 unsigned long flags;
125
126 cris_atomic_save(v, flags);
127 ret = v->counter;
128 if (likely(ret == old))
129 v->counter = new;
130 cris_atomic_restore(v, flags);
131 return ret;
132}
133
134#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
135
136static inline int __atomic_add_unless(atomic_t *v, int a, int u)
137{
138 int ret;
139 unsigned long flags;
140
141 cris_atomic_save(v, flags);
142 ret = v->counter;
143 if (ret != u)
144 v->counter += a;
145 cris_atomic_restore(v, flags);
146 return ret;
147}
148
149#endif