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
npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a claude-codeWhat 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_driverto 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_driverusingdevm_ioremap. - Show the
probeandremovelifecycle 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-code2Manually: put the files in place
~/.claude/skills/platform-device-model/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/platform-device-model/
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a codex2Manually: put the files in place
.agents/skills/platform-device-model/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a cursor2Manually: put the files in place
.cursor/skills/platform-device-model/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install mohitmishra786/low-level-dev-skills skills/kernel-dev/platform-device-model2Manually: put the files in place
.github/skills/platform-device-model/SKILL.md1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a gemini-cli2Platform CLI
gemini skills install https://github.com/mohitmishra786/low-level-dev-skills --path skills/kernel-dev/platform-device-modelManually: put the files in place
.devin/skills/platform-device-model/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill platform-device-model -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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