]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/tile/include/asm/atomic.h
tile: support atomic64_dec_if_positive()
[karo-tx-linux.git] / arch / tile / include / asm / atomic.h
index f2461429a4a4004b474e5024447b4a11200d4fa3..e71387ab20cacce942a3b5742fc1ad1c0ab88cdf 100644 (file)
@@ -131,4 +131,25 @@ static inline int atomic_read(const atomic_t *v)
 #include <asm/atomic_64.h>
 #endif
 
+#ifndef __ASSEMBLY__
+
+static inline long long atomic64_dec_if_positive(atomic64_t *v)
+{
+       long long c, old, dec;
+
+       c = atomic64_read(v);
+       for (;;) {
+               dec = c - 1;
+               if (unlikely(dec < 0))
+                       break;
+               old = atomic64_cmpxchg((v), c, dec);
+               if (likely(old == c))
+                       break;
+               c = old;
+       }
+       return dec;
+}
+
+#endif /* __ASSEMBLY__ */
+
 #endif /* _ASM_TILE_ATOMIC_H */