Skip to main content
skill CX Codex

platform-device-model — Claude Code skill: use and install

The platform-device-model skill explains Linux platform-driver binding, probe and remove, sysfs, device properties, and deferred probing for kernel work.

MIT 378 installs ★ 298 updated 2026-06-27

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a claude-code
Open on GitHub

What platform-device-model does

The skill maps the Linux device model around struct device, device_driver, and bus objects, then applies it to a platform_driver lifecycle. It covers resource lookup, devm_* cleanup, platform_set_drvdata, and the probe and remove callbacks. Examples also read DT or ACPI properties and expose driver state through a sysfs attribute.

A separate workflow covers -EPROBE_DEFER, platform-bus inspection under /sys/bus/platform, debugfs, and udevadm. It also guides a legacy board-file to Device Tree conversion. A missing supplier driver can leave deferred probing retrying forever. The examples use platform_get_resource, devm_ioremap_resource, and device_property_read_u32.

What it helps with

  • bind a platform_driver to a Linux device
  • convert a legacy board-file driver to Device Tree
  • map a memory resource with devm_ioremap_resource
  • expose driver status through sysfs
  • diagnose a deferred probe that never completes

Example prompts for the agent

  • Convert this legacy board-file driver to a DT platform_driver using devm_ioremap.
  • Show the probe and remove lifecycle for this platform device with managed cleanup.
  • Add a sysfs status attribute and show how to inspect it under /sys/bus/platform.

How to install platform-device-model

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a claude-code

2Manually: put the files in place

~/.claude/skills/platform-device-model/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/platform-device-model/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about platform-device-model

How do I install platform-device-model in Claude Code?

Run npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a claude-code, then check ~/.claude/skills/platform-device-model/SKILL.md.

What does platform-device-model do?

It helps implement and debug Linux platform-bus drivers, including device binding, resource access, DT or ACPI properties, sysfs attributes, and deferred probing.

Which platforms support platform-device-model?

The skill is available for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode.

Source text

SKILL.md · MIT
---
name: platform-device-model
description: Platform device model skill for Linux driver binding. Use when implementing platform_driver probe/remove, sysfs attributes, device properties, or deferred probe. Activates on queries about platform_device, platform_driver, driver model, sysfs, probe remove, or Linux device bus.
---

# Platform Device Model

## Purpose

Explain the Linux driver model for platform (and similar) buses: `struct device`, `device_driver`, `probe`/`remove`, resource acquisition, sysfs, and deferred probe — the glue between device tree and driver code.

## When to Use

- Implementing or debugging `platform_driver` lifecycle
- Exposing driver state via sysfs
- Understanding uevent / `udev` device node creation
- Before `skills/kernel-dev/writing-char-drivers`

## Workflow

### 1. Object hierarchy

```
bus_type (platform, amba, pci, i2c, spi)
├── struct device        — hardware instance
└── struct device_driver — driver logic
        └── probe(dev) / remove(dev)
```

Platform devices often come from DT (`of_platform`) or legacy board files.

### 2. Platform driver skeleton

```c
static int my_probe(struct platform_device *pdev)
{
    struct resource *res;
    void __iomem *base;

    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    base = devm_ioremap_resource(&pdev->dev, res);
    if (IS_ERR(base))
        return PTR_ERR(base);

    platform_set_drvdata(pdev, priv);
    return 0;
}

static void my_remove(struct platform_device *pdev)
{
    /* devm_* auto-cleanup on remove */
}

static struct platform_driver my_pdrv = {
    .probe  = my_probe,
    .remove = my_remove,
    .driver = {
        .name = "my-dev",
        .of_match_table = my_of_match,
    },
};
module_platform_driver(my_pdrv);
```

Prefer `devm_*` helpers for automatic unwind.

### 3. Device properties (DT / ACPI)

```c
u32 speed;
device_property_read_u32(&pdev->dev, "clock-speed", &speed);
bool flag = device_property_present(&pdev->dev, "feature-x");
```

### 4. Sysfs (driver visibility)

```c
static ssize_t status_show(struct device *dev,
                           struct device_attribute *attr, char *buf)
{
    return sysfs_emit(buf, "ok\n");
}
static DEVICE_ATTR_RO(status);

/* in probe */
device_create_file(&pdev->dev, &dev_attr_status);
```

### 5. Deferred probe

Return `-EPROBE_DEFER` when a clock, regulator, or bus is not ready — core retries later.

### 6. Debug

```bash
ls /sys/bus/platform/devices/
ls /sys/bus/platform/drivers/
cat /sys/kernel/debug/devices_deferred  # if debugfs enabled
udevadm monitor
```

### 7. Agent usage

```
/platform-device-model Convert legacy board file driver to DT platform_driver with devm_ioremap
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| `-EBUSY` on probe | Resource claimed twice | Check `status` / duplicate nodes |
| No `/dev` node | Char device not registered | See `writing-char-drivers` |
| Deferred forever | Supplier driver missing | Fix DT dependency chain |
| Remove crash | Manual free vs devm mismatch | Use devm consistently |
| Name mismatch | `.name` vs `compatible` | OF uses `of_match_table` |

## Related Skills

- `skills/kernel-dev/device-tree` — hardware description
- `skills/kernel/device-drivers` — IRQ, DMA, regmap depth
- `skills/kernel-dev/writing-char-drivers` — userspace interface
- `skills/kernel-dev/bus-drivers-i2c-spi` — other bus types
- `skills/low-level-programming/linux-kernel-modules` — module loading

© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills

Similar skills

SKILL.md skills catalog →

From the same set140

The whole set →
branch-prediction-and-speculation branch-prediction-and-speculation is a Claude Code skill that explains CPU branch prediction and speculative execution to help optimize hot loops and protect code from cache timing leaks. CX Codex +1 382installs os-dev-scratch os-dev-scratch is a Claude Code skill for building a minimal x86-64 OS, from boot stages to drivers and context switching. It activates on questions about kernel boot, interrupts, page tables, or QEMU. CX Codex +1 381installs kernel-security kernel-security — a skill for SELinux and AppArmor policies, seccomp-bpf sandboxing, KASLR, Intel CET, ARM PAC and BTI. Write LSM rules, triage kernel CVEs, and configure kernel mitigations. CX Codex +1 381installs peripherals-from-datasheet peripherals-from-datasheet guides driver development directly from MCU reference manuals. Helpful when writing bare-metal register code without a vendor HAL or migrating peripherals across chips. CX Codex +1 380installs writing-char-drivers writing-char-drivers — a skill for writing Linux character drivers: cdev registration, file_operations implementation, safe userspace copies, ioctl and mmap. CX Codex +1 378installs adc-dac-baremetal adc-dac-baremetal — a skill for bare-metal ADC and DAC setup on MCUs: channel selection, sampling time, calibration, DMA buffers, and voltage output. Essential when working with analog sensors, audio signals, or control voltages. CX Codex +1 378installs resource-optimization-lowend The resource-optimization-lowend skill helps trim flash and RAM use in MCU firmware, inspect linker maps, and measure stack depth when embedded resources are tight. CX Codex +1 376installs llvm-passes llvm-passes guides coding agents in creating, building, and verifying LLVM optimization passes with the New Pass Manager. CX Codex +1 373installs

Project sponsors

Companies that keep this analytics open