While reading "Linux kernel development" by Robert Love, I found at page 119:
The interrupt handler is normally marked static because it is never called directly from another file.
For example:
static irqreturn_t intr_handler(int irq, void *dev)
But why it is so? I doubt this function is going to be called by the kernel and if we make it static, then how is the kernel going to call it?
According to this, the way the function is used is by "registering" it with the kernel. That is, there's a function such as InstallIntHdlr
which you call and pass a pointer to your handler. The kernel can then use that pointer to call the function itself.
My guess, though I'm not sure about this, is that static
is used as a way of enforcing the proper usage of an interrupt handler. That is, since static functions can't be called from other files, it forces you to pass a pointer to it instead of calling it directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With