Skip to content

Day38 Log - IIO Sysfs Control

📅 Summary

Implemented sysfs control interface for IIO driver.


✅ Achievements

  • Added sampling_frequency via IIO standard API
  • Added fifo_enable as private attribute
  • Added watermark as private attribute
  • Replaced module parameter usage
  • Verified read/write from user-space

🔍 Observations

Sysfs Nodes

/sys/bus/iio/devices/iio:device0/
  ├── sampling_frequency
  ├── fifo_enable
  ├── watermark

Valid Writes

  • FIFO enable toggled correctly
  • Watermark updated correctly
  • Sampling frequency applied

Invalid Writes

  • Out-of-range values rejected
  • Kernel returned -EINVAL

Runtime Protection

  • Changes rejected during streaming
  • -EBUSY correctly returned

⚠️ Issues / Notes

  • FIFO disabled by default (intentional)
  • DRDY mode not implemented
  • FIFO disable does not switch acquisition mode

🧠 Learnings

  • IIO control plane uses sysfs, not ioctl
  • Helper functions should not perform locking
  • State consistency requires write-through design
  • Separation of control plane and data path is critical

🚀 Next Steps

  • Expose available ranges (sampling_frequency_available)
  • Define explicit acquisition modes (FIFO vs DRDY)
  • Move watermark to buffer subsystem (optional)