Appendix B: Kernel Interfaces

Choosing the right interface for exposing driver functionality.

Decision Guide

flowchart TB
    Q["Need to expose something?"]
    Q --> Q1{"For users or debugging?"}
    Q1 -->|Users| Q2{"Device config or generic?"}
    Q1 -->|Debugging| DEBUGFS["debugfs"]
    Q2 -->|Device config| SYSFS["sysfs<br/>(DEVICE_ATTR)"]
    Q2 -->|System-wide| PROCFS["procfs<br/>(if legacy)"]
    Q2 -->|User-configurable| CONFIGFS["configfs"]

    style SYSFS fill:#7a8f73,stroke:#2e7d32
    style DEBUGFS fill:#738f99,stroke:#0277bd

Quick Comparison

Interface Use For Stable ABI? Example
sysfs Device attributes Yes /sys/class/leds/*/brightness
debugfs Debug info, testing No /sys/kernel/debug/my_driver/
procfs System/process info Yes (legacy) /proc/cpuinfo
configfs User-defined objects Yes /sys/kernel/config/usb_gadget/

Recommendations

Scenario Use
Device-specific attribute sysfs (DEVICE_ATTR)
Hardware register dump debugfs
Debug statistics debugfs
New system info sysfs (avoid procfs for new code)
User creates objects configfs

Chapters

Chapter What You’ll Learn
sysfs DEVICE_ATTR, attribute groups
debugfs Debug interfaces

Example

Further Reading


Table of contents


Back to top

Linux Driver Development Guide is a community resource for learning kernel driver development. Not affiliated with the Linux Foundation. Content provided for educational purposes.

This site uses Just the Docs, a documentation theme for Jekyll.