agentleFS
oghieoghie/skillsets/skills/device-driver-development/SKILL.md

device-driver-development

Skill9 starsChanged 5 months agoMITView on GitHub

Use when developing, reviewing, debugging, porting, or engineering Linux kernel device drivers, kernel modules, device tree bindings, bus clients, subsystem drivers, DMA/IRQ/memory paths, userspace interfaces, or hardware bring-up plans.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 9 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat every driver task as hardware contract engineering: identify the kernel version, hardware bus, subsystem owner, execution context, …

    line 16
  2. Very specific:

    Use references/knowledge-map.md for the driver domain map and conceptual model.

    line 19
  3. Distinctive:

    Treat API details as version-sensitive.

    line 20
  4. Distinctive:

    Prefer an existing kernel subsystem over a private char driver when the device matches a framework.

    line 40
  5. Distinctive:

    Keep policy in userspace and mechanism in kernel.

    line 41
  6. Distinctive:

    Never sleep in atomic context.

    line 42
  7. Very specific:

    Use copy_{to,from}_user() only at ABI boundaries and handle partial copy/error paths.

    line 43
  8. Very specific:

    Run scripts/driver_static_scan.py <path> for heuristic review of C, Kconfig, Makefile, DTS, and binding files.

    line 49
  9. Very specific:

    Run scripts/module_smoke_build.sh <module-dir> [kernel-build-dir] for out-of-tree build smoke checks.

    line 50
  10. Very specific:

    Run scripts/tooling_probe.sh to inspect local build, static-analysis, tracing, fuzzing, QEMU, and KGDB tool availability.

    line 51
  11. Distinctive:

    Test load/unload, probe/remove failure paths, hot/unplug or unbind where applicable, suspend/resume if resources are power-managed.

    line 55
  12. Distinctive:

    Use QEMU/KGDB for isolated crash reproduction and Syzkaller for fuzzable ABI surfaces when practical.

    line 57
  13. Distinctive:

    Do not claim correctness from compilation alone.

    line 58
  14. Distinctive:

    When answering, name assumptions, selected subsystem, key APIs, file layout, validation commands, and residual hardware risks.

    line 61

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Device Driver Development

Core Rule

Treat every driver task as hardware contract engineering: identify the kernel version, hardware bus, subsystem owner, execution context, lifetime model, and userspace ABI before writing code.

Knowledge Grounding

  • Use references/knowledge-map.md for the driver domain map and conceptual model.
  • Treat API details as version-sensitive; verify callback signatures, helpers, and bindings against the active kernel tree or current kernel docs.

First Pass

  1. Classify the device: char, platform, I2C, SPI, regmap, IIO, GPIO, IRQ controller, input, RTC, PWM, regulator, framebuffer, or NIC.
  2. Identify interface surfaces: /dev, sysfs, debugfs, ioctl, mmap, netdev, IIO buffers, input events, DT binding, or kernel consumer API.
  3. Choose probe/remove lifetime: prefer devm_*, explicit unwind only when ordering or shared state requires it.
  4. Decide concurrency boundaries: process context, atomic context, IRQ top half, threaded IRQ, workqueue, timer, DMA callback.
  5. Define evidence needed: datasheet registers, bus transaction examples, DT node, logs, scope/logic-analyzer traces, and test plan.

Required Reads By Task

  • New driver or hardware bring-up: tasks/bringup-workflow.md.
  • Implementing subsystem callbacks: tasks/implementation-patterns.md and references/subsystem-matrix.md.
  • Memory, MMIO, mmap, DMA, IRQ, locking: references/kernel-engineering-principles.md.
  • Debugging, validation, or intermittent behavior: tasks/debugging-testing.md.
  • Toolchain, QEMU, KGDB, bpftrace, Smatch, Coccinelle, Syzkaller, Bootlin: references/tooling-matrix.md.
  • Auditable engineering flow: tasks/step-verify-workflow.md.
  • Upstream-ready patches or long-term maintenance: tasks/upstream-maintenance.md.
  • Final review before handoff: references/review-checklist.md.

Design Heuristics

  • Prefer an existing kernel subsystem over a private char driver when the device matches a framework.
  • Keep policy in userspace and mechanism in kernel; avoid inventing ABI without necessity.
  • Never sleep in atomic context; never hold spinlocks across bus calls that may sleep.
  • Use copy_{to,from}_user() only at ABI boundaries and handle partial copy/error paths.
  • For MMIO use devm_ioremap_resource() plus accessor APIs; do not dereference __iomem.
  • For register devices on I2C/SPI, consider regmap before custom read/write helpers.
  • For DT, model hardware, not Linux driver internals; document compatibles and supplies/clocks/IRQs/GPIOs.

Script Helpers

  • Run scripts/driver_static_scan.py <path> for heuristic review of C, Kconfig, Makefile, DTS, and binding files.
  • Run scripts/module_smoke_build.sh <module-dir> [kernel-build-dir] for out-of-tree build smoke checks.
  • Run scripts/tooling_probe.sh to inspect local build, static-analysis, tracing, fuzzing, QEMU, and KGDB tool availability.

Verification Gate

  • Build with warnings enabled and, when available, sparse, Smatch, Coccinelle, checkpatch.pl, dt_binding_check, and subsystem selftests.
  • Test load/unload, probe/remove failure paths, hot/unplug or unbind where applicable, suspend/resume if resources are power-managed.
  • Capture runtime evidence: dmesg, /proc/interrupts, sysfs state, tracepoints/ftrace/bpftrace, bus transactions, and userspace API results.
  • Use QEMU/KGDB for isolated crash reproduction and Syzkaller for fuzzable ABI surfaces when practical.
  • Do not claim correctness from compilation alone; tie each claim to a code path, runtime observation, or documented subsystem contract.

Output Standard

When answering, name assumptions, selected subsystem, key APIs, file layout, validation commands, and residual hardware risks. If source evidence is missing, say what must be measured or read next.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.