From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>,
Roland Dreier <roland@kernel.org>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
Mike Marciniszyn <infinipath@qlogic.com>,
linux-rdma@vger.kernel.org
Subject: [PATCH 1/4] IB/ipath: use for_each_set_bit and for_each_set_bit_from
Date: Tue, 3 Apr 2012 17:47:13 +0900 [thread overview]
Message-ID: <1333442836-9947-1-git-send-email-akinobu.mita@gmail.com> (raw)
Use for_each_set_bit() and for_each_set_bit_from() to iterate over all
the set bit in a memory region.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: Mike Marciniszyn <infinipath@qlogic.com>
Cc: linux-rdma@vger.kernel.org
---
drivers/infiniband/hw/ipath/ipath_file_ops.c | 17 +++--------------
drivers/infiniband/hw/ipath/ipath_intr.c | 5 ++---
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 736d9ed..f74079e 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -438,10 +438,7 @@ static int ipath_tid_update(struct ipath_portdata *pd, struct file *fp,
if (limit > tidcnt)
/* just in case size changes in future */
limit = tidcnt;
- tid = find_first_bit((const unsigned long *)tidmap, limit);
- for (; tid < limit; tid++) {
- if (!test_bit(tid, tidmap))
- continue;
+ for_each_set_bit(tid, tidmap, limit) {
if (dd->ipath_pageshadow[porttid + tid]) {
ipath_cdbg(VERBOSE, "Freeing TID %u\n",
tid);
@@ -548,16 +545,8 @@ static int ipath_tid_free(struct ipath_portdata *pd, unsigned subport,
ipath_cdbg(VERBOSE, "Port%u free %u tids; first bit (max=%d) "
"set is %d, porttid %u\n", pd->port_port, ti->tidcnt,
limit, tid, porttid);
- for (cnt = 0; tid < limit; tid++) {
- /*
- * small optimization; if we detect a run of 3 or so without
- * any set, use find_first_bit again. That's mainly to
- * accelerate the case where we wrapped, so we have some at
- * the beginning, and some at the end, and a big gap
- * in the middle.
- */
- if (!test_bit(tid, tidmap))
- continue;
+ cnt = 0;
+ for_each_set_bit_from(tid, tidmap, limit) {
cnt++;
if (dd->ipath_pageshadow[porttid + tid]) {
struct page *p;
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index c0a03ac..ee8d0d7 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -79,9 +79,8 @@ void ipath_disarm_senderrbufs(struct ipath_devdata *dd)
printk("\n");
}
- for (i = 0; i < piobcnt; i++)
- if (test_bit(i, sbuf))
- ipath_disarm_piobufs(dd, i, 1);
+ for_each_set_bit(i, sbuf, piobcnt)
+ ipath_disarm_piobufs(dd, i, 1);
/* ignore armlaunch errs for a bit */
dd->ipath_lastcancel = jiffies+3;
}
--
1.7.4.4
next reply other threads:[~2012-04-03 8:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 8:47 Akinobu Mita [this message]
2012-04-03 8:47 ` [PATCH 2/4] IB/qib: use for_each_set_bit and for_each_set_bit_from Akinobu Mita
2012-04-03 8:47 ` [PATCH 3/4] arm: davinci: use for_each_set_bit_from Akinobu Mita
2012-04-10 16:42 ` Sekhar Nori
2012-04-10 21:08 ` Akinobu Mita
[not found] ` <CABkLObr4Vyp9FwxfOquFjqnh1rEaLXNAzBV4SV-PO=UA4EC2vA@mail.gmail.com>
2012-04-10 21:02 ` Akinobu Mita
2012-04-03 8:47 ` [PATCH 4/4] ppp: " 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=1333442836-9947-1-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hal.rosenstock@gmail.com \
--cc=infinipath@qlogic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=roland@kernel.org \
--cc=sean.hefty@intel.com \
/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