linuxlinux-kernelinterruptirq

convert HW IRQ to Linux IRQ


I have a HW_IRQ is shared between 2 kernel modules. Module1 is loaded at the boot time and called: request_irq(linux_irq1, handler1, IRQF_SHARED, ...);. After booting up, I want to load the Module2 that shared the same HW_IRQ with the Module1. I need to call request_irq(linux_irq2, handler2, IRQF_SHARED, ...);. Actually 'linux_irq2' is equal to 'linux_irq1', but in Module2 I can not access to private data of Module1. Do you know how to convert HW_IRQ to 'linux_irq2' in Module2?

Module2 as a patch of Module1, it has no Device Tree node.


Solution

  • We can map HW IRQ to Linux IRQ by this:

    u32 irq;
    struct irq_desc *desc;
    
    for (irq = 0; irq < NR_IRQS; irq++) {
        desc = irq_to_desc(irq);
        if (desc && desc->irq_data.hwirq == hwirq)
            return desc->irq_data.irq;
    }