Day26 - Sensor Core and Bus Layer Refactor¶
🎯 Objective¶
Transform a single-file I2C driver into:
- Bus-agnostic core
- Separate I2C transport layer
🧩 Steps¶
Step 1 - Introduce bus abstraction¶
Replace direct I2C calls:
With:
Step 2 - Extract core logic¶
Move to mysensor_core.c:
- cache handling
- update logic
- polling / IRQ
- sysfs / hwmon
Step 3 - Create I2C glue layer¶
File: mysensor_i2c.c
Contains:
- i2c_driver
- probe/remove
- bus_ops implementation
Step 4 - Modify probe flow¶
Step 5 - Update Makefile¶
✅ Validation Checklist¶
- Module loads successfully
- hwmon interface works
- IRQ mode works
- Polling mode works
- Hybrid mode works
- Cooldown logic works
- debug_status is correct
🔍 Verification Commands¶
dmesg | tail
cat /sys/class/hwmon/hwmonX/temp1_input
cat /sys/class/hwmon/hwmonX/device/debug_status