IB/ipath: use for_each_set_bit and for_each_set_bit_from
Subsystems (6)
PATCH 1/4 IB/ipath: use for_each_set_bit and for_each_set_bit_from
Use for_each_set_bit() and for_each_set_bit_from() to iterate over all the set bit in a memory region.
--- drivers/infiniband/hw/ipath/ipath_file_ops.c | 17 +++-------------- drivers/infiniband/hw/ipath/ipath_intr.c | 5 ++--- 2 files changed, 5 insertions(+), 17 deletions(-)
drivers/infiniband/hw/ipath/ipath_file_ops.c +3 -14
@@ -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;
drivers/infiniband/hw/ipath/ipath_intr.c +2 -3
@@ -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 ; }
Signature · 1 line
1.7.4.4
PATCH 2/4 IB/qib: use for_each_set_bit and for_each_set_bit_from
Use for_each_set_bit() and for_each_set_bit_from() to iterate over all the set bit in a memory region.
--- drivers/infiniband/hw/qib/qib_file_ops.c | 22 ++++------------------ drivers/infiniband/hw/qib/qib_tx.c | 14 +++++--------- 2 files changed, 9 insertions(+), 27 deletions(-)
drivers/infiniband/hw/qib/qib_file_ops.c +4 -18
@@ -399,10 +399,7 @@ cleanup: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->pageshadow[ctxttid + tid]) {dma_addr_t phys;
@@ -504,17 +501,8 @@ static int qib_tid_free(struct qib_ctxtdata *rcd, unsigned subctxt,if (limit > tidcnt)/* just in case size changes in future */ limit = tidcnt; - tid =find_first_bit (tidmap, limit); -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 (tid, tidmap, limit) { cnt++;if (dd->pageshadow[ctxttid + tid]) {struct page *p;
@@ -1948,9 +1936,7 @@ static int qib_user_event_ack(struct qib_ctxtdata *rcd, int subctxt, {int ret =0 , i; -for (i =0 ; i <= _QIB_MAX_EVENT_BIT; i++) { -if (!test_bit (i, &events)) -continue ; +for_each_set_bit (i, &events, _QIB_MAX_EVENT_BIT +1 ) {if (i == _QIB_EVENT_DISARM_BUFS_BIT) { (void )qib_disarm_piobufs_ifneeded (rcd); ret =disarm_req_delay (rcd);
drivers/infiniband/hw/qib/qib_tx.c +5 -9
@@ -82,7 +82,6 @@ int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *rcd)struct qib_devdata *dd = rcd->dd;unsigned i;unsigned last; -unsigned n =0 ; last = rcd->pio_base + rcd->piocnt;/*
@@ -101,11 +100,10 @@ int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *rcd) &rcd->user_event_mask[i]); }spin_lock_irq (&dd->pioavail_lock); -for (i = rcd->pio_base; i < last; i++) { -if (__test_and_clear_bit (i, dd->pio_need_disarm)) { - n++; - dd->f_sendctrl (rcd->ppd,QIB_SENDCTRL_DISARM_BUF (i)); - } + i = rcd->pio_base; +for_each_set_bit_from (i, dd->pio_need_disarm, last) { +__clear_bit (i, dd->pio_need_disarm); + dd->f_sendctrl (rcd->ppd,QIB_SENDCTRL_DISARM_BUF (i)); }spin_unlock_irq (&dd->pioavail_lock);return 0 ;
@@ -178,10 +176,8 @@ void qib_disarm_piobufs_set(struct qib_devdata *dd, unsigned long *mask,for (i =0 ; i < dd->num_pports; i++) pppd[i] =NULL ; -for (i =0 ; i < cnt; i++) { +for_each_set_bit (i, mask, cnt) {int which; -if (!test_bit (i, mask)) -continue ;/* * If the buffer is owned by the DMA hardware, * reset the DMA engine.
Signature · 1 line
1.7.4.4
PATCH 3/4 arm: davinci: use for_each_set_bit_from
In reply to Akinobu MitaUse for_each_set_bit_from to iterate over all the set bit in a memory region.
--- arch/arm/mach-davinci/dma.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-davinci/dma.c +3 -3
@@ -557,9 +557,9 @@ static int reserve_contiguous_slots(int ctlr, unsigned int id,if (i == edma_cc[ctlr]->num_slots) stop_slot = i; -for (j = start_slot; j < stop_slot; j++) -if (test_bit (j, tmp_inuse)) -clear_bit (j, edma_cc[ctlr]->edma_inuse); + j = start_slot; +for_each_set_bit_from (j, tmp_inuse, stop_slot); +clear_bit (j, edma_cc[ctlr]->edma_inuse);if (count)return -EBUSY ;
Signature · 1 line
1.7.4.4
Re: [PATCH 3/4] arm: davinci: use for_each_set_bit_from
Hi Akinobu,
Quoted 9 lines · Akinobu Mita
Use
for_each_set_bit_fromto iterate over all the set bit in a memory region.Signed-off-by Akinobu Mita <[email protected]>Cc Sekhar Nori <[email protected]>Cc Kevin Hilman <[email protected]>Cc davinci-linux-open-source at linux.davincidsp.comCc Russell King <[email protected]>Cc linux-arm-kernel at lists.infradead.org
Looks good to me. If you are planning to send this upstream outside of davinci tree, please add my:
Else, let me know and I will be happy to queue it.
Thanks,
Sekhar
Re: [PATCH 3/4] arm: davinci: use for_each_set_bit_from
2012/4/11 Sekhar Nori <[email protected]>:
Quoted 13 lines
Hi Akinobu,
Quoted 9 lines · Akinobu Mita
Use
for_each_set_bit_fromto iterate over all the set bit in a memory region.Signed-off-by Akinobu Mita <[email protected]>Cc Sekhar Nori <[email protected]>Cc Kevin Hilman <[email protected]>Cc davinci-linux-open-source at linux.davincidsp.comCc Russell King <[email protected]>Cc linux-arm-kernel at lists.infradead.org
Quoted 6 lines
Looks good to me. If you are planning to send this upstream outside of davinci tree, please add my:
Acked-by Sekhar Nori <[email protected]>Else, let me know and I will be happy to queue it.
Christian found a bug in this patch. So I'll resend it, then please queue it to your tree.
A message that is not in the archive (sent off-list or not yet received): CABkLObr4Vyp9FwxfOquFjqnh1rEaLXNAzBV4SV-PO=UA4EC2vA@mail.gmail.com
Re: [PATCH 3/4] arm: davinci: use for_each_set_bit_from
2012/4/11 Christian Riesch <[email protected]>:
Quoted 7 lines
Quoted 7 lines
arch/arm/mach-davinci/dma.c +0
-0@@ -557,9 +557,9 @@ static int reserve_contiguous_slots(int ctlr, unsignedint id, ? ? ? ?if (i == edma_cc[ctlr]->num_slots) ? ? ? ? ? ? ? ?stop_slot = i;
Quoted 7 lines
arch/arm/mach-davinci/dma.c static int reserve_contiguous_slots(int ctlr, unsigned · line 562
Quoted 5 lines
arch/arm/mach-davinci/dma.c +2
-3- ? ? ? for (j = start_slot; j < stop_slot; j++) - ? ? ? ? ? ? ? if (test_bit(j, tmp_inuse)) - ? ? ? ? ? ? ? ? ? ? ? clear_bit(j, edma_cc[ctlr]->edma_inuse); + ? ? ? j = start_slot; + ? ? ? for_each_set_bit_from(j, tmp_inuse, stop_slot);Is the semicolon at the end of the line correct?
It's clearly a bug that I was going to introduce. I'll fix and resend it.
Thanks a lot.
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-davinci/dma.c +1
-0+ ? ? ? ? ? ? ? clear_bit(j, edma_cc[ctlr]->edma_inuse); ? ? ? ?if (count)? ? ? ? ? ? ? ?return
-EBUSY;
--
1.7.4.4--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html Please read the FAQ at ?http://www.tux.org/lkml/
PATCH 4/4 ppp: use for_each_set_bit_from
In reply to Akinobu MitaUse for_each_set_bit_from to iterate over all the set bit in a memory region.
--- drivers/net/ppp/pptp.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ppp/pptp.c +2 -2
@@ -116,8 +116,8 @@ static int lookup_chan_dst(u16 call_id, __be32 d_addr)int i;rcu_read_lock (); -for (i =find_next_bit (callid_bitmap,MAX_CALLID ,1 ); i <MAX_CALLID ; - i =find_next_bit (callid_bitmap,MAX_CALLID , i +1 )) { + i =1 ; +for_each_set_bit_from (i, callid_bitmap,MAX_CALLID ) { sock =rcu_dereference (callid_sock[i]);if (!sock)continue ;
Signature · 1 line
1.7.4.4