[PATCH 4/5] genirq: Use the common function irq_expand_nr_irqs()

From: Shanker Donthineni
Date: Sun Jan 29 2023 - 19:58:03 EST


When the !SPARSEIRQ code path is executed, the function
irq_expand_nr_irqs() returns -ENOMEM. However, the SPARSEIRQ
version of the function can be safely used in both cases, as
nr_irqs = MAX_SPARSE_IRQS = NR_IRQS.

Signed-off-by: Shanker Donthineni <sdonthineni@xxxxxxxxxx>
---
kernel/irq/irqdesc.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index aacfb4826c5e..247a0718d028 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -144,6 +144,14 @@ static unsigned int irq_find_next_irq(unsigned int offset)
return find_next_bit(allocated_irqs, nr_irqs, offset);
}

+static int irq_expand_nr_irqs(unsigned int nr)
+{
+ if (nr > MAX_SPARSE_IRQS)
+ return -ENOMEM;
+ nr_irqs = nr;
+ return 0;
+}
+
#ifdef CONFIG_SPARSE_IRQ

static void irq_kobj_release(struct kobject *kobj);
@@ -528,14 +536,6 @@ static int alloc_descs(unsigned int start, unsigned int cnt, int node,
return -ENOMEM;
}

-static int irq_expand_nr_irqs(unsigned int nr)
-{
- if (nr > MAX_SPARSE_IRQS)
- return -ENOMEM;
- nr_irqs = nr;
- return 0;
-}
-
int __init early_irq_init(void)
{
int i, initcnt, node = first_online_node;
@@ -630,11 +630,6 @@ static inline int alloc_descs(unsigned int start, unsigned int cnt, int node,
return start;
}

-static int irq_expand_nr_irqs(unsigned int nr)
-{
- return -ENOMEM;
-}
-
void irq_mark_irq(unsigned int irq)
{
mutex_lock(&sparse_irq_lock);
--
2.25.1