Why make an interrupt handler like static.is necessary?

While reading a book (Linux kernel development by Robert Love) there is no page: 119 I got "The interrupt handler is normally marked static because it is never called directly from another file."

e, g

 static irqreturn_t intr_handler(int irq, void *dev) 

but why this is so, I doubt that this function will be called by the kernel, and if we make it static, then how the kernel will call it.

+4
source share
1 answer

According to this , the way to use the function is to "register" it with the kernel. That is, there is a function, such as InstallIntHdlr , that you call and pass a pointer to your handler. Then the kernel can use this pointer to call the function itself.

My assumption, although I'm not sure about this, is that static used as a way to ensure proper use of the interrupt handler. That is, since static functions cannot be called from other files, this forces you to pass a pointer to it, rather than calling it directly.

+5
source

Source: https://habr.com/ru/post/1492639/


All Articles