Day 14 - Event-driven GPIO Driver¶
📅 Date¶
YYYY-MM-DD
🎯 Goal¶
Convert GPIO driver into event-driven model with:
- IRQ + deferred work
- Event queue
- Blocking / non-blocking read
- poll support
✅ What I Learned¶
1. Event-driven design¶
- read() returns events, not state
- behaves like stream
2. ISR design¶
- ISR must be minimal
- use deferred work
3. Debounce¶
- use delayed_work
- avoid false triggers
4. Ring buffer¶
- FIFO queue
- avoid losing ordering
5. Blocking read¶
- wait queue instead of busy loop
6. Non-blocking behavior¶
- return
-EAGAIN
7. poll/select integration¶
- enables event-driven user-space design
8. Driver removal¶
- wake up readers
- return
-ENODEV
🐞 Issues Encountered¶
1. llseek compile error¶
no_llseeknot available- replaced with
noop_llseek
2. O_NONBLOCK logic bug¶
- fixed condition inversion
3. wait_event condition¶
- added
shutting_down
🧠 Reflection¶
This driver is no longer a simple char device.
It behaves like:
- input driver
- event device
- asynchronous system component
🚀 Next Step (Day 15)¶
- poll / select / epoll deep dive
- user-space event loop
- multi-device monitoring