struct platform_driver¶
Purpose¶
struct platform_driver describes a kernel driver that binds to platform devices, often created from Device Tree nodes.
It is commonly used for simple SoC peripherals, GPIO-based devices, and board-specific devices.
Header¶
Typical Structure¶
static struct platform_driver my_driver = {
.probe = my_probe,
.remove = my_remove,
.driver = {
.name = "my-driver",
.of_match_table = my_of_match,
},
};
Key Fields¶
| Field | Purpose |
|---|---|
.probe |
Called when a matching device is found |
.remove |
Called when the device or driver is removed |
.driver.name |
Driver name |
.driver.of_match_table |
Device Tree match table |
Common Pitfalls¶
probe()not called because the Device Tree overlay is not loadedcompatiblestring mismatch- missing required Device Tree properties
- resource cleanup not handled through devm helpers