Index: linux-2.6/include/asm-ppc64/atomic.h =================================================================== --- linux-2.6.orig/include/asm-ppc64/atomic.h +++ linux-2.6/include/asm-ppc64/atomic.h @@ -164,6 +164,23 @@ static __inline__ int atomic_dec_return( #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +/** + * atomic_inc_not_zero - increment if not zero + * @v: pointer of type atomic_t + * + * Atomically increments @v by 1, so long as it was not 0. + * Returns non-zero on successful increment and zero otherwise. + */ +#define atomic_inc_not_zero(v) \ +({ \ + int c, old; \ + c = atomic_read(v); \ + while (c && (old = atomic_cmpxchg((v), c, c + 1)) != c) \ + c = old; \ + c; \ +}) + + #define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0) #define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0)