diff options
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 | ||