[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240620175703.605111-8-yury.norov@gmail.com>
Date: Thu, 20 Jun 2024 10:56:30 -0700
From: Yury Norov <yury.norov@...il.com>
To: linux-kernel@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Rob Herring <robh@...nel.org>,
Sam Ravnborg <sam@...nborg.org>,
Yury Norov <yury.norov@...il.com>,
sparclinux@...r.kernel.org
Cc: Alexey Klimov <alexey.klimov@...aro.org>,
Bart Van Assche <bvanassche@....org>,
Jan Kara <jack@...e.cz>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>,
Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Sergey Shtylyov <s.shtylyov@....ru>
Subject: [PATCH v4 07/40] sparc: optimize alloc_msi() by using find_and_set_bit()
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@...il.com>
---
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@...emloft.net)
*/
+#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
Powered by blists - more mailing lists