Re: Can't understand /proc/interrupts output for GICv3 case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 12, 2022 at 03:51:24PM +0900, Chan Kim wrote:
> Hi Greg KH and all,
> 
> I found how to find the irq number in my case! (char driver kernel module)
> I want to share it for reference to others.
> 
> add these two header files for this.
> #include <linux/irq.h>
> #include <linux/irqdesc.h>
> 
> extern struct irq_desc *irq_to_desc(unsigned int irq);
> struct irq_desc *desc;
> 
> in the module _init function :
> 
> // find my irq number
>     for(i=0;i<NR_IRQS;i++){
>         desc = irq_to_desc(i);
>         if (desc) {
>             //printk("irq_desc(%d)->irq_data.hwirq = %ld\n", i,
> desc->irq_data.hwirq);
>             if (desc->irq_data.hwirq == 47) break; // 47 is the hwirq
> number, (SPI 15)
>         }
>     }

No, please no.  Do NOT do this, it will break and not work well over
time, if it even works at all right now you are lucky.  Odds are, when
you reboot, it will not as irq numbers are never guaranteed to be the
same across boots.

Again, use the irq number given to you by your platform device bus.  It
should be much simpler than "iterate over all irqs and guess which one
we want to take" like you did here.

good luck!

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux