Skip to content

Commit a1ceb83

Browse files
committed
genirq/manage: Rework can_request_irq()
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 <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 8589e32 commit a1ceb83

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

include/linux/irq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ extern void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret);
700700
extern int noirqdebug_setup(char *str);
701701

702702
/* Checks whether the interrupt can be requested by request_irq(): */
703-
extern int can_request_irq(unsigned int irq, unsigned long irqflags);
703+
extern bool can_request_irq(unsigned int irq, unsigned long irqflags);
704704

705705
/* Dummy irq-chip implementations: */
706706
extern struct irq_chip no_irq_chip;

kernel/irq/manage.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -888,22 +888,17 @@ EXPORT_SYMBOL(irq_set_irq_wake);
888888
* particular irq has been exclusively allocated or is available
889889
* for driver use.
890890
*/
891-
int can_request_irq(unsigned int irq, unsigned long irqflags)
891+
bool can_request_irq(unsigned int irq, unsigned long irqflags)
892892
{
893-
unsigned long flags;
894-
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
895-
int canrequest = 0;
896-
897-
if (!desc)
898-
return 0;
893+
scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_GLOBAL) {
894+
struct irq_desc *desc = scoped_irqdesc;
899895

900-
if (irq_settings_can_request(desc)) {
901-
if (!desc->action ||
902-
irqflags & desc->action->flags & IRQF_SHARED)
903-
canrequest = 1;
896+
if (irq_settings_can_request(desc)) {
897+
if (!desc->action || irqflags & desc->action->flags & IRQF_SHARED)
898+
return true;
899+
}
904900
}
905-
irq_put_desc_unlock(desc, flags);
906-
return canrequest;
901+
return false;
907902
}
908903

909904
int __irq_set_trigger(struct irq_desc *desc, unsigned long flags)

0 commit comments

Comments
 (0)