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 <[email protected]> Cc: Roland Dreier <[email protected]> Cc: Sean Hefty <[email protected]> Cc: Hal Rosenstock <[email protected]> Cc: Mike Marciniszyn <[email protected]> Cc: [email protected] --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
