One, interrupt handler function
The interrupt handler function runs in the interrupt context and cannot be preempted or dispatched.
There are a few things to note about interrupt context programming:
Cannot sleep or call schedule to abandon CPU
You cannot call any function that may sleep, for example: to get the semaphore
The user spatial data cannot be accessed, for example: Copy_from_user, because it is not executed in the context of the process.
Execution time as short as possible
int REQUEST_IRQ (unsigned int IRQ, irq_handler_t handler, unsigned long flags, const char *name, void *dev_id)
Request interrupted, return 0 indicates success, negative number indicates error code
IRQ: Interrupt Number
Handler: Interrupt handler function
Flags: Interrupt Flag
Name: Interrupt name, displayed in/proc/interrupts
DEV_ID: Used as a shared interrupt pointer to identify different shared interrupt int
void Free_irq (unigned int IRQ, void *dev_id)
Release interrupts
Interrupt handler function is generally installed when the driver is initialized or when the device is first opened, and the interrupt line is limited on the system, so it is wasteful to install the interrupt handler when the driver is initialized, which is usually installed when the device is opened for the first time. Using FREE_IRQ is usually the last time the device is closed.
[Linux drivers] [Linux Interrupt]--Interrupt processing