From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: linux-s390@vger.kernel.org, linux-usb@vger.kernel.org,
Robert Richter <robert.richter@amd.com>,
x86@kernel.org, Heiko Carstens <heiko.carstens@de.ibm.com>,
Akinobu Mita <akinobu.mita@gmail.com>,
Ingo Molnar <mingo@redhat.com>,
linux-mtd@lists.infradead.org, "H. Peter Anvin" <hpa@zytor.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
linux390@de.ibm.com, Thomas Gleixner <tglx@linutronix.de>,
David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH 3/7] bitops: introduce list_for_each_clear_bit
Date: Sat, 14 Jan 2012 00:53:20 +0900 [thread overview]
Message-ID: <1326470004-10096-4-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1326470004-10096-1-git-send-email-akinobu.mita@gmail.com>
Introduce list_for_each_clear_bit() and list_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: x86@kernel.org
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
Cc: linux-usb@vger.kernel.org
---
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 15ad702..c8a0d65 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -32,6 +32,17 @@ extern unsigned long __sw_hweight64(__u64 w);
(bit) < (size); \
(bit) = find_next_bit((addr), (size), (bit) + 1))
+#define for_each_clear_bit(bit, addr, size) \
+ for ((bit) = find_first_zero_bit((addr), (size)); \
+ (bit) < (size); \
+ (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
+
+/* same as for_each_clear_bit() but use bit as value to start with */
+#define for_each_clear_bit_from(bit, addr, size) \
+ for ((bit) = find_next_zero_bit((addr), (size), (bit)); \
+ (bit) < (size); \
+ (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
+
static __inline__ int get_bitmask_order(unsigned int count)
{
int order;
--
1.7.4.4
next prev parent reply other threads:[~2012-01-13 15:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-13 15:53 [PATCH 0/7] bitops: introduce for_each_clear_bit() Akinobu Mita
2012-01-13 15:53 ` Akinobu Mita [this message]
2012-01-13 17:16 ` [PATCH 3/7] bitops: introduce list_for_each_clear_bit Sergei Shtylyov
2012-01-13 23:36 ` Akinobu Mita
2012-01-13 15:53 ` [PATCH 5/7] s390/char: use for_each_clear_bit Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326470004-10096-4-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dwmw2@infradead.org \
--cc=heiko.carstens@de.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=mingo@redhat.com \
--cc=robert.richter@amd.com \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox