@@ -632,14 +632,8 @@ void irq_init_desc(unsigned int irq)
632
632
633
633
#endif /* !CONFIG_SPARSE_IRQ */
634
634
635
- /**
636
- * generic_handle_irq - Invoke the handler for a particular irq
637
- * @irq: The irq number to handle
638
- *
639
- */
640
- int generic_handle_irq (unsigned int irq )
635
+ int handle_irq_desc (struct irq_desc * desc )
641
636
{
642
- struct irq_desc * desc = irq_to_desc (irq );
643
637
struct irq_data * data ;
644
638
645
639
if (!desc )
@@ -652,6 +646,17 @@ int generic_handle_irq(unsigned int irq)
652
646
generic_handle_irq_desc (desc );
653
647
return 0 ;
654
648
}
649
+ EXPORT_SYMBOL_GPL (handle_irq_desc );
650
+
651
+ /**
652
+ * generic_handle_irq - Invoke the handler for a particular irq
653
+ * @irq: The irq number to handle
654
+ *
655
+ */
656
+ int generic_handle_irq (unsigned int irq )
657
+ {
658
+ return handle_irq_desc (irq_to_desc (irq ));
659
+ }
655
660
EXPORT_SYMBOL_GPL (generic_handle_irq );
656
661
657
662
#ifdef CONFIG_HANDLE_DOMAIN_IRQ
@@ -668,27 +673,32 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,
668
673
bool lookup , struct pt_regs * regs )
669
674
{
670
675
struct pt_regs * old_regs = set_irq_regs (regs );
671
- unsigned int irq = hwirq ;
676
+ struct irq_desc * desc ;
672
677
int ret = 0 ;
673
678
674
679
irq_enter ();
675
680
676
- #ifdef CONFIG_IRQ_DOMAIN
677
- if (lookup )
678
- irq = irq_find_mapping (domain , hwirq );
679
- #endif
680
-
681
- /*
682
- * Some hardware gives randomly wrong interrupts. Rather
683
- * than crashing, do something sensible.
684
- */
685
- if (unlikely (!irq || irq >= nr_irqs )) {
686
- ack_bad_irq (irq );
687
- ret = - EINVAL ;
681
+ if (likely (IS_ENABLED (CONFIG_IRQ_DOMAIN ) && lookup )) {
682
+ /* The irqdomain code provides boundary checks */
683
+ desc = irq_resolve_mapping (domain , hwirq );
688
684
} else {
689
- generic_handle_irq (irq );
685
+ /*
686
+ * Some hardware gives randomly wrong interrupts. Rather
687
+ * than crashing, do something sensible.
688
+ */
689
+ if (unlikely (!hwirq || hwirq >= nr_irqs )) {
690
+ ack_bad_irq (hwirq );
691
+ desc = NULL ;
692
+ } else {
693
+ desc = irq_to_desc (hwirq );
694
+ }
690
695
}
691
696
697
+ if (likely (desc ))
698
+ handle_irq_desc (desc );
699
+ else
700
+ ret = - EINVAL ;
701
+
692
702
irq_exit ();
693
703
set_irq_regs (old_regs );
694
704
return ret ;
@@ -709,22 +719,22 @@ int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq,
709
719
struct pt_regs * regs )
710
720
{
711
721
struct pt_regs * old_regs = set_irq_regs (regs );
712
- unsigned int irq ;
722
+ struct irq_desc * desc ;
713
723
int ret = 0 ;
714
724
715
725
/*
716
726
* NMI context needs to be setup earlier in order to deal with tracing.
717
727
*/
718
728
WARN_ON (!in_nmi ());
719
729
720
- irq = irq_find_mapping (domain , hwirq );
730
+ desc = irq_resolve_mapping (domain , hwirq );
721
731
722
732
/*
723
733
* ack_bad_irq is not NMI-safe, just report
724
734
* an invalid interrupt.
725
735
*/
726
- if (likely (irq ))
727
- generic_handle_irq ( irq );
736
+ if (likely (desc ))
737
+ handle_irq_desc ( desc );
728
738
else
729
739
ret = - EINVAL ;
730
740
0 commit comments