Skip to content

Driver Control Plane

A driver often needs two kinds of interfaces:

  • data path: moving data or events
  • control plane: configuring driver behavior

In this repo, the control plane was explored with both ioctl and sysfs.

Data Path vs Control Plane

Interface Type Purpose Examples
Data path Transfer data or events read, write, poll
Control plane Configure behavior or inspect state ioctl, sysfs attributes

ioctl

ioctl is useful when the control command is strongly tied to a device file and may require structured data.

/dev/mygpio
    ↓ ioctl(fd, CMD, arg)
driver unlocked_ioctl()

sysfs

sysfs is useful for simple configuration and status attributes.

/sys/class/.../attribute
    ↓ read/write text values
driver show/store callbacks

Design Guidance

Requirement Better Fit
Simple text status sysfs
Simple integer configuration sysfs
Structured command data ioctl
Per-open file state ioctl
Debug or inspection interface sysfs

Common Pitfalls

Warning

Do not put high-frequency data paths into sysfs. sysfs is not designed for streaming data.

Warning

Validate all user-provided data in ioctl and sysfs store callbacks.