Skip to content

GPIO and IRQ Driver

A GPIO IRQ driver converts hardware edge events into software events. In this repo, GPIO interrupts were used as the foundation for event-driven character drivers, debounce logic, pollable drivers, and user-space notification models.

Basic Flow

GPIO input edge
IRQ handler / threaded IRQ
update driver state or event queue
wake_up_interruptible()
read() / poll() / epoll() in user space

IRQ Handler Design

A good IRQ design keeps the hard interrupt path short and defers heavier work to a safer context.

Common options:

Mechanism Typical Use
Hard IRQ handler Acknowledge event, capture minimal state
Threaded IRQ Sleepable interrupt processing
Workqueue Deferred processing outside interrupt context
Timer / delayed work Debounce or delayed validation

Debounce Pattern

GPIO IRQ
schedule delayed work
read stable GPIO value
push event into queue
wake readers

Common Pitfalls

Warning

Do not sleep in a hard IRQ handler. Use a threaded IRQ, workqueue, or delayed work when the code may sleep.

Warning

An IRQ event should not be lost just because user space is not currently blocked in read(). Use driver state or an event queue.