Skip to content

Commit 509853f

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
genirq: Provide generic_handle_irq_safe()
Provide generic_handle_irq_safe() which can used from any context. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Oleksandr Natalenko <oleksandr@natalenko.name> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/20220211181500.1856198-2-bigeasy@linutronix.de
1 parent cfb9244 commit 509853f

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

include/linux/irqdesc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static inline void generic_handle_irq_desc(struct irq_desc *desc)
160160

161161
int handle_irq_desc(struct irq_desc *desc);
162162
int generic_handle_irq(unsigned int irq);
163+
int generic_handle_irq_safe(unsigned int irq);
163164

164165
#ifdef CONFIG_IRQ_DOMAIN
165166
/*

kernel/irq/irqdesc.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,29 @@ int generic_handle_irq(unsigned int irq)
662662
}
663663
EXPORT_SYMBOL_GPL(generic_handle_irq);
664664

665+
/**
666+
* generic_handle_irq_safe - Invoke the handler for a particular irq from any
667+
* context.
668+
* @irq: The irq number to handle
669+
*
670+
* Returns: 0 on success, a negative value on error.
671+
*
672+
* This function can be called from any context (IRQ or process context). It
673+
* will report an error if not invoked from IRQ context and the irq has been
674+
* marked to enforce IRQ-context only.
675+
*/
676+
int generic_handle_irq_safe(unsigned int irq)
677+
{
678+
unsigned long flags;
679+
int ret;
680+
681+
local_irq_save(flags);
682+
ret = handle_irq_desc(irq_to_desc(irq));
683+
local_irq_restore(flags);
684+
return ret;
685+
}
686+
EXPORT_SYMBOL_GPL(generic_handle_irq_safe);
687+
665688
#ifdef CONFIG_IRQ_DOMAIN
666689
/**
667690
* generic_handle_domain_irq - Invoke the handler for a HW irq belonging

0 commit comments

Comments
 (0)