Disabling / Enabling Interrupts
To disable interrupts locally for the current processor (and only the current processor) and then later reenable them, do the following:
local_irq_disable();
/* interrupts are disabled .. */
local_irq_enable();
The local_irq_disable()
routine is dangerous if interrupts were already disabled prior to its invocation. The corresponding call to local_irq_enable()
unconditionally enables interrupts, despite the fact that they were off to begin with. Instead, a mechanism is needed to restore interrupts to a previous state.
unsigned long flags;
local_irq_save(flags); /* interrupts disabled */
/*...*/
local_irq_restore(flags); /* interrupts restored to previous state */
flags
cannot be passed to another function (specifically, it must remain on the same stack frame). For this reason, the call to save and the call to restore interrupts must occur in the same function.
Disabling only one interrupt line
The following functions allow you to disable only one interrupt line
void disable_irq(unsigned int irq);
void disable_irq_nosync(unsigned int irq);
void enable_irq(unsigned int irq);
void synchronize_irq(unsigned int irq);