Skip to content

Commit b5c7e7e

Browse files
committed
all: replace find_next{,_zero}_bit with find_first{,_zero}_bit where appropriate
find_first{,_zero}_bit is a more effective analogue of 'next' version if start == 0. This patch replaces 'next' with 'first' where things look trivial. Signed-off-by: Yury Norov <[email protected]> Tested-by: Wolfram Sang <[email protected]>
1 parent 93ba139 commit b5c7e7e

File tree

21 files changed

+47
-48
lines changed

21 files changed

+47
-48
lines changed

arch/powerpc/platforms/pasemi/dma_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ int pasemi_dma_alloc_flag(void)
375375
int bit;
376376

377377
retry:
378-
bit = find_next_bit(flags_free, MAX_FLAGS, 0);
378+
bit = find_first_bit(flags_free, MAX_FLAGS);
379379
if (bit >= MAX_FLAGS)
380380
return -ENOSPC;
381381
if (!test_and_clear_bit(bit, flags_free))
@@ -440,7 +440,7 @@ int pasemi_dma_alloc_fun(void)
440440
int bit;
441441

442442
retry:
443-
bit = find_next_bit(fun_free, MAX_FLAGS, 0);
443+
bit = find_first_bit(fun_free, MAX_FLAGS);
444444
if (bit >= MAX_FLAGS)
445445
return -ENOSPC;
446446
if (!test_and_clear_bit(bit, fun_free))

arch/s390/kvm/kvm-s390.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ static unsigned long kvm_s390_next_dirty_cmma(struct kvm_memslots *slots,
20212021
while ((slotidx > 0) && (ofs >= ms->npages)) {
20222022
slotidx--;
20232023
ms = slots->memslots + slotidx;
2024-
ofs = find_next_bit(kvm_second_dirty_bitmap(ms), ms->npages, 0);
2024+
ofs = find_first_bit(kvm_second_dirty_bitmap(ms), ms->npages);
20252025
}
20262026
return ms->base_gfn + ofs;
20272027
}

drivers/block/rnbd/rnbd-clt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ rnbd_get_cpu_qlist(struct rnbd_clt_session *sess, int cpu)
196196
return per_cpu_ptr(sess->cpu_queues, bit);
197197
} else if (cpu != 0) {
198198
/* Search from 0 to cpu */
199-
bit = find_next_bit(sess->cpu_queues_bm, cpu, 0);
199+
bit = find_first_bit(sess->cpu_queues_bm, cpu);
200200
if (bit < cpu)
201201
return per_cpu_ptr(sess->cpu_queues, bit);
202202
}

drivers/dma/ti/edma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data)
16811681

16821682
dev_dbg(ecc->dev, "EMR%d 0x%08x\n", j, val);
16831683
emr = val;
1684-
for (i = find_next_bit(&emr, 32, 0); i < 32;
1684+
for (i = find_first_bit(&emr, 32); i < 32;
16851685
i = find_next_bit(&emr, 32, i + 1)) {
16861686
int k = (j << 5) + i;
16871687

drivers/iio/adc/ad7124.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static int ad7124_find_free_config_slot(struct ad7124_state *st)
347347
{
348348
unsigned int free_cfg_slot;
349349

350-
free_cfg_slot = find_next_zero_bit(&st->cfg_slots_status, AD7124_MAX_CONFIGS, 0);
350+
free_cfg_slot = find_first_zero_bit(&st->cfg_slots_status, AD7124_MAX_CONFIGS);
351351
if (free_cfg_slot == AD7124_MAX_CONFIGS)
352352
return -1;
353353

drivers/infiniband/hw/irdma/hw.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,14 +1709,14 @@ static enum irdma_status_code irdma_setup_init_state(struct irdma_pci_f *rf)
17091709
*/
17101710
static void irdma_get_used_rsrc(struct irdma_device *iwdev)
17111711
{
1712-
iwdev->rf->used_pds = find_next_zero_bit(iwdev->rf->allocated_pds,
1713-
iwdev->rf->max_pd, 0);
1714-
iwdev->rf->used_qps = find_next_zero_bit(iwdev->rf->allocated_qps,
1715-
iwdev->rf->max_qp, 0);
1716-
iwdev->rf->used_cqs = find_next_zero_bit(iwdev->rf->allocated_cqs,
1717-
iwdev->rf->max_cq, 0);
1718-
iwdev->rf->used_mrs = find_next_zero_bit(iwdev->rf->allocated_mrs,
1719-
iwdev->rf->max_mr, 0);
1712+
iwdev->rf->used_pds = find_first_zero_bit(iwdev->rf->allocated_pds,
1713+
iwdev->rf->max_pd);
1714+
iwdev->rf->used_qps = find_first_zero_bit(iwdev->rf->allocated_qps,
1715+
iwdev->rf->max_qp);
1716+
iwdev->rf->used_cqs = find_first_zero_bit(iwdev->rf->allocated_cqs,
1717+
iwdev->rf->max_cq);
1718+
iwdev->rf->used_mrs = find_first_zero_bit(iwdev->rf->allocated_mrs,
1719+
iwdev->rf->max_mr);
17201720
}
17211721

17221722
void irdma_ctrl_deinit_hw(struct irdma_pci_f *rf)

drivers/media/cec/core/cec-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int __must_check cec_devnode_register(struct cec_devnode *devnode,
106106

107107
/* Part 1: Find a free minor number */
108108
mutex_lock(&cec_devnode_lock);
109-
minor = find_next_zero_bit(cec_devnode_nums, CEC_NUM_DEVICES, 0);
109+
minor = find_first_zero_bit(cec_devnode_nums, CEC_NUM_DEVICES);
110110
if (minor == CEC_NUM_DEVICES) {
111111
mutex_unlock(&cec_devnode_lock);
112112
pr_err("could not get a free minor\n");

drivers/media/mc/mc-devnode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ int __must_check media_devnode_register(struct media_device *mdev,
217217

218218
/* Part 1: Find a free minor number */
219219
mutex_lock(&media_devnode_lock);
220-
minor = find_next_zero_bit(media_devnode_nums, MEDIA_NUM_DEVICES, 0);
220+
minor = find_first_zero_bit(media_devnode_nums, MEDIA_NUM_DEVICES);
221221
if (minor == MEDIA_NUM_DEVICES) {
222222
mutex_unlock(&media_devnode_lock);
223223
pr_err("could not get a free minor\n");

drivers/pci/controller/dwc/pci-dra7xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static int dra7xx_pcie_handle_msi(struct pcie_port *pp, int index)
213213
if (!val)
214214
return 0;
215215

216-
pos = find_next_bit(&val, MAX_MSI_IRQS_PER_CTRL, 0);
216+
pos = find_first_bit(&val, MAX_MSI_IRQS_PER_CTRL);
217217
while (pos != MAX_MSI_IRQS_PER_CTRL) {
218218
generic_handle_domain_irq(pp->irq_domain,
219219
(index * MAX_MSI_IRQS_PER_CTRL) + pos);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17990,8 +17990,8 @@ lpfc_sli4_alloc_xri(struct lpfc_hba *phba)
1799017990
* the driver starts at 0 each time.
1799117991
*/
1799217992
spin_lock_irq(&phba->hbalock);
17993-
xri = find_next_zero_bit(phba->sli4_hba.xri_bmask,
17994-
phba->sli4_hba.max_cfg_param.max_xri, 0);
17993+
xri = find_first_zero_bit(phba->sli4_hba.xri_bmask,
17994+
phba->sli4_hba.max_cfg_param.max_xri);
1799517995
if (xri >= phba->sli4_hba.max_cfg_param.max_xri) {
1799617996
spin_unlock_irq(&phba->hbalock);
1799717997
return NO_XRI;
@@ -19668,7 +19668,7 @@ lpfc_sli4_alloc_rpi(struct lpfc_hba *phba)
1966819668
max_rpi = phba->sli4_hba.max_cfg_param.max_rpi;
1966919669
rpi_limit = phba->sli4_hba.next_rpi;
1967019670

19671-
rpi = find_next_zero_bit(phba->sli4_hba.rpi_bmask, rpi_limit, 0);
19671+
rpi = find_first_zero_bit(phba->sli4_hba.rpi_bmask, rpi_limit);
1967219672
if (rpi >= rpi_limit)
1967319673
rpi = LPFC_RPI_ALLOC_ERROR;
1967419674
else {
@@ -20311,8 +20311,8 @@ lpfc_sli4_fcf_rr_next_index_get(struct lpfc_hba *phba)
2031120311
* have been tested so that we can detect when we should
2031220312
* change the priority level.
2031320313
*/
20314-
next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask,
20315-
LPFC_SLI4_FCF_TBL_INDX_MAX, 0);
20314+
next_fcf_index = find_first_bit(phba->fcf.fcf_rr_bmask,
20315+
LPFC_SLI4_FCF_TBL_INDX_MAX);
2031620316
}
2031720317

2031820318

0 commit comments

Comments
 (0)