module_driver(9)
π module_driver(9) β the kernel API manual, bestie edition π
Okay so real talk: this one lives in the kernel API manual and it's a macro, capital-M Macro, and she is here to save you from typing the same boring init/exit boilerplate forever. β¨
πΈ NAME πΈ
module_driver β the helper macro for drivers that don't do anything special in module init/exit. It eliminates a lot of boilerplate. Like, a lot. π«Ά
Two things you absolutely cannot skip, bestie:
- Each module may only use this macro once. One and done. No double-dipping. π
- Calling it replaces
module_init()andmodule_exit(). Not "adds to" β replaces. So don't go calling those too, okay?
β¨ SYNOPSIS β¨
module_driver (__driver , __register , __unregister , ... );
That's the whole vibe. Four slots, one macro, zero drama. π
π¦ ARGUMENTS π¦
__driverβ the driver name. That's it, that's the whole description. Her name. π__registerβ the register function for this driver type. The "put it in the system" one. π₯__unregisterβ the unregister function for this driver type. The "take it back out" one. π...β additional arguments to be passed to__registerand__unregister. Extra toppings, both ways. π
π DESCRIPTION π
Bestie, listen closely, this is the important part:
Use this macro to construct bus specific macros for registering drivers β and do not use it on its own. π¨
It's giving "template for a template". She's the blueprint you build other macros out of, not something you slap directly into your driver. Respect the pipeline. β¨
π§ SEE ALSO π§
- Kernel file
./include/linux/device/driver.h enum probe_type(9)struct device_driver(9)driver_find_device_by_name(9)driver_find_device_by_of_node(9)driver_find_device_by_fwnode(9)driver_find_device_by_devt(9)driver_find_device_by_acpi_dev(9)builtin_driver(9)
π Go read struct device_driver(9) next, iykyk. It's the main character of this whole friend group.
Okay that's the page!! Mwah π β this one's from ./include/linux/device, dated October 2026, and honestly? She ate. Periodt. πππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms