Day 17 - sysfs vs ioctl¶
Summary¶
Implemented sysfs attribute (debounce_ms) and compared it with ioctl.
What I Learned¶
- sysfs is part of Linux device model
- sysfs attributes are tied to struct device
- device_create() 4th argument is critical (drvdata)
- sysfs and ioctl can share the same backend state
Debug Experience¶
- sysfs file existed but cat failed
- root cause: dev_get_drvdata(dev) returned NULL
- fixed by passing mydev into device_create()
Key Insight¶
Control plane can have multiple interfaces:
- sysfs (text-based)
- ioctl (binary)
But both must operate on the same internal state.
Design Thinking¶
- sysfs is ideal for simple configuration (debounce_ms)
- ioctl is better for structured control (GET_STATUS, CLR_EVENTS)
- read/poll is for event data
Reflection¶
This is the first time I clearly see separation of:
- data plane (read/poll)
- control plane (sysfs/ioctl)
The design is much cleaner and more scalable.