kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: 'Greg KH' <greg@kroah.com>
To: Chan Kim <ckim@etri.re.kr>
Cc: 'qemu-discuss' <qemu-discuss@nongnu.org>,
	kernelnewbies@kernelnewbies.org
Subject: Re: Can't understand /proc/interrupts output for GICv3 case
Date: Tue, 12 Apr 2022 12:14:47 +0200	[thread overview]
Message-ID: <YlVRF/OG+0sGaQ/B@kroah.com> (raw)
In-Reply-To: <080101d84e39$b9eed890$2dcc89b0$@etri.re.kr>

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@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2022-04-12 10:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08  4:53 Can't understand /proc/interrupts output for GICv3 case Chan Kim
2022-04-11 12:36 ` Chan Kim
2022-04-11 12:49   ` Greg KH
2022-04-11 13:13     ` Chan Kim
2022-04-11 13:34       ` 'Greg KH'
2022-04-11 14:15         ` Chan Kim
2022-04-11 14:26           ` 'Greg KH'
2022-04-12  2:18             ` Chan Kim
2022-04-12  4:50               ` 'Greg KH'
2022-04-12  4:54                 ` Chan Kim
2022-04-12  6:51                   ` Chan Kim
2022-04-12 10:14                     ` 'Greg KH' [this message]
2022-04-11 14:32           ` Peter Maydell
2022-04-11 14:49             ` Greg KH
2022-04-11 14:58               ` Peter Maydell
2022-04-11 14:59               ` Ozgur Karatas
2022-04-11 14:53           ` Ozgur Karatas
2022-04-12  2:43             ` Chan Kim
2022-04-12  7:14               ` Ozgur Karatas
2022-04-12  7:22                 ` Chan Kim
2022-04-12  7:29                   ` Ozgur Karatas
2022-04-11 13:09   ` Ozgur Kara
2022-04-11 13:16     ` Chan Kim
2022-04-11 13:28       ` Ozgur Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YlVRF/OG+0sGaQ/B@kroah.com \
    --to=greg@kroah.com \
    --cc=ckim@etri.re.kr \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=qemu-discuss@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).