summaryrefslogtreecommitdiffstats
path: root/arch/frv
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2017-01-24 18:18:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-24 19:26:14 -0500
commit4180c4c170a5a33b9987b314d248a9d572d89ab0 (patch)
tree3b7e9665d5b6789a6f3e92991f9cd0253b11034d /arch/frv
parente47483bca2cc59a4593b37a270b16ee42b1d9f08 (diff)
frv: add missing atomic64 operations
Some more atomic64 operations were missing and as a result frv allmodconfig was failing. Add the missing operations. Link: http://lkml.kernel.org/r/1485193844-12850-1-git-send-email-sudip.mukherjee@codethink.co.uk Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Cc: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/frv')
-rw-r--r--arch/frv/include/asm/atomic.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
index 994ed3d5ca08..e93c9494503a 100644
--- a/arch/frv/include/asm/atomic.h
+++ b/arch/frv/include/asm/atomic.h
@@ -139,7 +139,7 @@ static inline void atomic64_dec(atomic64_t *v)
139#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i), (v)) == 0) 139#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i), (v)) == 0)
140#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0) 140#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
141#define atomic64_inc_and_test(v) (atomic64_inc_return((v)) == 0) 141#define atomic64_inc_and_test(v) (atomic64_inc_return((v)) == 0)
142 142#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
143 143
144#define atomic_cmpxchg(v, old, new) (cmpxchg(&(v)->counter, old, new)) 144#define atomic_cmpxchg(v, old, new) (cmpxchg(&(v)->counter, old, new))
145#define atomic_xchg(v, new) (xchg(&(v)->counter, new)) 145#define atomic_xchg(v, new) (xchg(&(v)->counter, new))
@@ -177,6 +177,23 @@ static inline int atomic64_add_unless(atomic64_t *v, long long i, long long u)
177 return c != u; 177 return c != u;
178} 178}
179 179
180static inline long long atomic64_dec_if_positive(atomic64_t *v)
181{
182 long long c, old, dec;
183
184 c = atomic64_read(v);
185 for (;;) {
186 dec = c - 1;
187 if (unlikely(dec < 0))
188 break;
189 old = atomic64_cmpxchg((v), c, dec);
190 if (likely(old == c))
191 break;
192 c = old;
193 }
194 return dec;
195}
196
180#define ATOMIC_OP(op) \ 197#define ATOMIC_OP(op) \
181static inline int atomic_fetch_##op(int i, atomic_t *v) \ 198static inline int atomic_fetch_##op(int i, atomic_t *v) \
182{ \ 199{ \