atomic: Add atomic_or()
authorPaul E. McKenney <paul.mckenney@linaro.org>
Wed, 11 May 2011 12:33:33 +0000 (05:33 -0700)
committerIngo Molnar <mingo@elte.hu>
Sat, 28 May 2011 15:41:46 +0000 (17:41 +0200)
An atomic_or() function is needed by TREE_RCU to avoid deadlock, so
add a generic version.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/atomic.h

index 96c038e43d667ad04d15cec41841d2f2606cb816..ee456c79b0e6784cb8af04fcddbc3f354030b59f 100644 (file)
@@ -34,4 +34,17 @@ static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
 }
 #endif
 
+#ifndef CONFIG_ARCH_HAS_ATOMIC_OR
+static inline void atomic_or(int i, atomic_t *v)
+{
+       int old;
+       int new;
+
+       do {
+               old = atomic_read(v);
+               new = old | i;
+       } while (atomic_cmpxchg(v, old, new) != old);
+}
+#endif /* #ifndef CONFIG_ARCH_HAS_ATOMIC_OR */
+
 #endif /* _LINUX_ATOMIC_H */