[S390] atomic: implement atomic64_dec_if_positive

Implement atomic64_dec_if_positive and add missing system.h header
include.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by Heiko Carstens and committed by Martin Schwidefsky 2ddb3ec4 1ef6acf5

+19
+19
arch/s390/include/asm/atomic.h
··· 15 15 16 16 #include <linux/compiler.h> 17 17 #include <linux/types.h> 18 + #include <asm/system.h> 18 19 19 20 #define ATOMIC_INIT(i) { (i) } 20 21 ··· 275 274 static inline int atomic64_add_unless(atomic64_t *v, long long a, long long u) 276 275 { 277 276 long long c, old; 277 + 278 278 c = atomic64_read(v); 279 279 for (;;) { 280 280 if (unlikely(c == u)) ··· 286 284 c = old; 287 285 } 288 286 return c != u; 287 + } 288 + 289 + static inline long long atomic64_dec_if_positive(atomic64_t *v) 290 + { 291 + long long c, old, dec; 292 + 293 + c = atomic64_read(v); 294 + for (;;) { 295 + dec = c - 1; 296 + if (unlikely(dec < 0)) 297 + break; 298 + old = atomic64_cmpxchg((v), c, dec); 299 + if (likely(old == c)) 300 + break; 301 + c = old; 302 + } 303 + return dec; 289 304 } 290 305 291 306 #define atomic64_add(_i, _v) atomic64_add_return(_i, _v)