skills/kernel-dev/platform-device-model/SKILL.md
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.
npx skillsauth add mohitmishra786/low-level-dev-skills platform-device-modelInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
platform_driver lifecycleudev device node creationskills/kernel-dev/writing-char-driversbus_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.
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.
u32 speed;
device_property_read_u32(&pdev->dev, "clock-speed", &speed);
bool flag = device_property_present(&pdev->dev, "feature-x");
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);
Return -EPROBE_DEFER when a clock, regulator, or bus is not ready — core retries later.
ls /sys/bus/platform/devices/
ls /sys/bus/platform/drivers/
cat /sys/kernel/debug/devices_deferred # if debugfs enabled
udevadm monitor
/platform-device-model Convert legacy board file driver to DT platform_driver with devm_ioremap
| 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 |
skills/kernel-dev/device-tree — hardware descriptionskills/kernel/device-drivers — IRQ, DMA, regmap depthskills/kernel-dev/writing-char-drivers — userspace interfaceskills/kernel-dev/bus-drivers-i2c-spi — other bus typesskills/low-level-programming/linux-kernel-modules — module loadingdevelopment
QEMU/KVM skill for virtualization and kernel development. Use when running qemu-system-x86_64 with KVM, configuring virtio devices, VFIO passthrough, QMP monitor, libvirt, or booting custom kernels. Activates on queries about QEMU, KVM, virtio, VFIO, virsh, virt-install, or -kernel -append.
development
Hardware virtualization internals skill for Intel VT-x and AMD-V. Use when studying VMCS/VMCB, EPT/NPT page tables, VMEXIT handling, APIC virtualization, or building minimal hypervisors. Activates on queries about VMX, SVM, VMCS, EPT, NPT, VMEXIT, or type-1 hypervisor.
testing
Linux containers internals skill for namespaces, cgroups, and OCI. Use when understanding clone/unshare namespaces, cgroups v2 limits, overlayfs, runc, seccomp profiles, capabilities, or escape mitigations. Activates on queries about namespaces, cgroups, overlayfs, runc, seccomp-bpf, OCI spec, or container escape.
tools
Reverse engineering skill for binary analysis. Use when decompiling with Ghidra, analyzing with radare2, scripting RE tools, triaging with strings/file/xxd, or diffing binaries. Activates on queries about Ghidra, radare2, r2, decompiler, Binary Ninja, Diaphora, or stripped binary analysis.