module_platform_driver()¶
Purpose¶
module_platform_driver() is a helper macro for registering and unregistering a platform driver in a loadable kernel module.
It reduces boilerplate for simple platform drivers.
Header¶
Typical Usage¶
static struct platform_driver my_driver = {
.probe = my_probe,
.remove = my_remove,
.driver = {
.name = "my-driver",
.of_match_table = my_of_match,
},
};
module_platform_driver(my_driver);
Equivalent Concept¶
It is equivalent to writing module init and exit functions that call:
Common Pitfalls¶
- missing
MODULE_DEVICE_TABLE(of, ...) - wrong
compatiblestring - probe not called because the Device Tree node does not match
- using this helper when custom init or exit ordering is required