diff options
author | Helge Deller <deller@gmx.de> | 2013-05-06 15:13:33 -0400 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2013-05-06 17:10:04 -0400 |
commit | f21dda025ab00da197ac30b6c6690c380d838683 (patch) | |
tree | 3059c205f6fe3cbbf5e098524aab36a64aabeecc /arch/parisc/include | |
parent | bbbfde782084b4f0d85ddffb88f1cf4650ff40e4 (diff) |
parisc: implement atomic64_dec_if_positive()
Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'arch/parisc/include')
-rw-r--r-- | arch/parisc/include/asm/atomic.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h index f38e1984b242..472886ceab1d 100644 --- a/arch/parisc/include/asm/atomic.h +++ b/arch/parisc/include/asm/atomic.h | |||
@@ -229,6 +229,29 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) | |||
229 | 229 | ||
230 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) | 230 | #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) |
231 | 231 | ||
232 | /* | ||
233 | * atomic64_dec_if_positive - decrement by 1 if old value positive | ||
234 | * @v: pointer of type atomic_t | ||
235 | * | ||
236 | * The function returns the old value of *v minus 1, even if | ||
237 | * the atomic variable, v, was not decremented. | ||
238 | */ | ||
239 | static inline long atomic64_dec_if_positive(atomic64_t *v) | ||
240 | { | ||
241 | long c, old, dec; | ||
242 | c = atomic64_read(v); | ||
243 | for (;;) { | ||
244 | dec = c - 1; | ||
245 | if (unlikely(dec < 0)) | ||
246 | break; | ||
247 | old = atomic64_cmpxchg((v), c, dec); | ||
248 | if (likely(old == c)) | ||
249 | break; | ||
250 | c = old; | ||
251 | } | ||
252 | return dec; | ||
253 | } | ||
254 | |||
232 | #endif /* !CONFIG_64BIT */ | 255 | #endif /* !CONFIG_64BIT */ |
233 | 256 | ||
234 | 257 | ||