alloc_msi() opencodes find_and_set_bit(). Simplify it by using the dedicated function, and make a nice one-liner. Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx> --- arch/sparc/kernel/pci_msi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/sparc/kernel/pci_msi.c b/arch/sparc/kernel/pci_msi.c index acb2f83a1d5c..55ff78a8f37c 100644 --- a/arch/sparc/kernel/pci_msi.c +++ b/arch/sparc/kernel/pci_msi.c @@ -3,6 +3,7 @@ * * Copyright (C) 2007 David S. Miller (davem@xxxxxxxxxxxxx) */ +#include <linux/find_atomic.h> #include <linux/kernel.h> #include <linux/interrupt.h> #include <linux/of.h> @@ -96,14 +97,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.43.0