Merge branch 'for-linus' of git://git.kernel.dk/linux-block
[deliverable/linux.git] / include / linux / bitops.h
index defeaac0745f1b26340d7a13f5b73810de743193..299e76b59fe9b0330254f608863f7237ed97c802 100644 (file)
@@ -227,6 +227,22 @@ static inline unsigned long __ffs64(u64 word)
 })
 #endif
 
+#ifndef bit_clear_unless
+#define bit_clear_unless(ptr, _clear, _test)   \
+({                                                             \
+       const typeof(*ptr) clear = (_clear), test = (_test);    \
+       typeof(*ptr) old, new;                                  \
+                                                               \
+       do {                                                    \
+               old = ACCESS_ONCE(*ptr);                        \
+               new = old & ~clear;                             \
+       } while (!(old & test) &&                               \
+                cmpxchg(ptr, old, new) != old);                \
+                                                               \
+       !(old & test);                                          \
+})
+#endif
+
 #ifndef find_last_bit
 /**
  * find_last_bit - find the last set bit in a memory region
This page took 0.024555 seconds and 5 git commands to generate.