]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
genirq/chip: Rework irq_set_chip()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 29 Apr 2025 06:55:19 +0000 (08:55 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 7 May 2025 07:08:13 +0000 (09:08 +0200)
Use the new guards to get and lock the interrupt descriptor and tidy up the
code.

Fixup the kernel doc comment while at it.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/20250429065421.295400891@linutronix.de
kernel/irq/chip.c

index daa356a94ab3feb12e80763795f3ff5acfaae391..92bf81aeba224442e9946da4967b7a36cd1b628c 100644 (file)
@@ -34,26 +34,22 @@ struct irqaction chained_action = {
 };
 
 /**
- *     irq_set_chip - set the irq chip for an irq
- *     @irq:   irq number
- *     @chip:  pointer to irq chip description structure
+ * irq_set_chip - set the irq chip for an irq
+ * @irq:       irq number
+ * @chip:      pointer to irq chip description structure
  */
 int irq_set_chip(unsigned int irq, const struct irq_chip *chip)
 {
-       unsigned long flags;
-       struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
-
-       if (!desc)
-               return -EINVAL;
+       int ret = -EINVAL;
 
-       desc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
-       irq_put_desc_unlock(desc, flags);
-       /*
-        * For !CONFIG_SPARSE_IRQ make the irq show up in
-        * allocated_irqs.
-        */
-       irq_mark_irq(irq);
-       return 0;
+       scoped_irqdesc_get_and_lock(irq, 0) {
+               scoped_irqdesc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
+               ret = 0;
+       }
+       /* For !CONFIG_SPARSE_IRQ make the irq show up in allocated_irqs. */
+       if (!ret)
+               irq_mark_irq(irq);
+       return ret;
 }
 EXPORT_SYMBOL(irq_set_chip);