diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2012-03-23 18:02:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 19:58:34 -0400 |
commit | 03f4a8226c2f9c14361f75848d1e93139bab90c4 (patch) | |
tree | c8c225f2debf749286c178897eaf2f802e50b0ab /include/linux/bitops.h | |
parent | 0a329d2d5a1dd75273597538cdc33512ee38855e (diff) |
bitops: introduce for_each_clear_bit()
Introduce for_each_clear_bit() and for_each_clear_bit_from(). They are
similar to for_each_set_bit() and list_for_each_set_bit_from(), but they
iterate over all the cleared bits in a memory region.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Stefano Panella <stefano.panella@csr.com>
Cc: David Vrabel <david.vrabel@csr.com>
Cc: Sergei Shtylyov <sshtylyov@mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r-- | include/linux/bitops.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 348b1dca477a..a3b6b82108b9 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -32,6 +32,17 @@ extern unsigned long __sw_hweight64(__u64 w); | |||
32 | (bit) < (size); \ | 32 | (bit) < (size); \ |
33 | (bit) = find_next_bit((addr), (size), (bit) + 1)) | 33 | (bit) = find_next_bit((addr), (size), (bit) + 1)) |
34 | 34 | ||
35 | #define for_each_clear_bit(bit, addr, size) \ | ||
36 | for ((bit) = find_first_zero_bit((addr), (size)); \ | ||
37 | (bit) < (size); \ | ||
38 | (bit) = find_next_zero_bit((addr), (size), (bit) + 1)) | ||
39 | |||
40 | /* same as for_each_clear_bit() but use bit as value to start with */ | ||
41 | #define for_each_clear_bit_from(bit, addr, size) \ | ||
42 | for ((bit) = find_next_zero_bit((addr), (size), (bit)); \ | ||
43 | (bit) < (size); \ | ||
44 | (bit) = find_next_zero_bit((addr), (size), (bit) + 1)) | ||
45 | |||
35 | static __inline__ int get_bitmask_order(unsigned int count) | 46 | static __inline__ int get_bitmask_order(unsigned int count) |
36 | { | 47 | { |
37 | int order; | 48 | int order; |