Skip to content

Commit e23b1c0

Browse files
sudipm-mukherjeegregkh
authored andcommitted
frv: add missing atomic64 operations
[ Upstream commit 4180c4c ] 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 <[email protected]> Cc: David Howells <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9186846 commit e23b1c0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

arch/frv/include/asm/atomic.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static inline void atomic64_dec(atomic64_t *v)
139139
#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i), (v)) == 0)
140140
#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
141141
#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)
143143

144144
#define atomic_cmpxchg(v, old, new) (cmpxchg(&(v)->counter, old, new))
145145
#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)
177177
return c != u;
178178
}
179179

180+
static 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+
180197
#define ATOMIC_OP(op) \
181198
static inline int atomic_fetch_##op(int i, atomic_t *v) \
182199
{ \

0 commit comments

Comments
 (0)