[PATCH v2 07/35] sparc: fix opencoded find_and_set_bit() in alloc_msi()

Yury Norov
2023-12-03T19:33:30Z

alloc_msi() opencodes find_and_clear_bit(). Switch it to using the
dedicated function, and make an nice one-liner.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
arch/sparc/kernel/pci_msi.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/sparc/kernel/pci_msi.c b/arch/sparc/kernel/pci_msi.c
index fc7402948b7b..91105c788d1d 100644
--- a/arch/sparc/kernel/pci_msi.c
+++ b/arch/sparc/kernel/pci_msi.c
@@ -96,14 +96,9 @@ static u32 pick_msiq(struct pci_pbm_info *pbm)

static int alloc_msi(struct pci_pbm_info *pbm)
{
- int i;
-
- for (i = 0; i < pbm->msi_num; i++) {
- if (!test_and_set_bit(i, pbm->msi_bitmap))
- return i + pbm->msi_first;
- }
+ int i = find_and_set_bit(pbm->msi_bitmap, pbm->msi_num);

- return -ENOENT;
+ return i < pbm->msi_num ? i + pbm->msi_first : -ENOENT;
}

static void free_msi(struct pci_pbm_info *pbm, int msi_num)
--
2.40.1