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

Make the return value boolean to reflect it's meaning.

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/20250429065422.187250840@linutronix.de
include/linux/irq.h
kernel/irq/manage.c

index dd5df1e2d032d8b857b4d952ba860116215ecfa1..df93b238b8bf12b85358218d34543c7c34b93f63 100644 (file)
@@ -700,7 +700,7 @@ extern void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret);
 extern int noirqdebug_setup(char *str);
 
 /* Checks whether the interrupt can be requested by request_irq(): */
-extern int can_request_irq(unsigned int irq, unsigned long irqflags);
+extern bool can_request_irq(unsigned int irq, unsigned long irqflags);
 
 /* Dummy irq-chip implementations: */
 extern struct irq_chip no_irq_chip;
index d1ff1e81d383dd39ece5336ce66f1f5716ed45ec..b6f057a6b8ae42e1496eb0af7b2d9a931042e8a6 100644 (file)
@@ -888,22 +888,17 @@ EXPORT_SYMBOL(irq_set_irq_wake);
  * particular irq has been exclusively allocated or is available
  * for driver use.
  */
-int can_request_irq(unsigned int irq, unsigned long irqflags)
+bool can_request_irq(unsigned int irq, unsigned long irqflags)
 {
-       unsigned long flags;
-       struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
-       int canrequest = 0;
-
-       if (!desc)
-               return 0;
+       scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) {
+               struct irq_desc *desc = scoped_irqdesc;
 
-       if (irq_settings_can_request(desc)) {
-               if (!desc->action ||
-                   irqflags & desc->action->flags & IRQF_SHARED)
-                       canrequest = 1;
+               if (irq_settings_can_request(desc)) {
+                       if (!desc->action || irqflags & desc->action->flags & IRQF_SHARED)
+                               return true;
+               }
        }
-       irq_put_desc_unlock(desc, flags);
-       return canrequest;
+       return false;
 }
 
 int __irq_set_trigger(struct irq_desc *desc, unsigned long flags)