Linux kernel wl18xx module_init is it generated?


Linux kernel wl18xx module_init is it generated?



I'm looking at this drivers/net/wireless/ti/wl18xx driver module.


drivers/net/wireless/ti/wl18xx



The traditional module_init() is not in the source code. Yet the trace dump shows a wl18xx_driver_init() is called, though that function again is not in the source code.


module_init()


wl18xx_driver_init()



I can see the wl18xx_driver_init() in the objdump of main.o in that driver directory.


wl18xx_driver_init()


main.o



Is it that in late versions of kernels those functions/macros are automatically generated? How is that done?




1 Answer
1



wl18xx_driver_init is generated here with the expansion of module_platform_driver(wl18xx_driver) macro.
It expands roughly to smth like:


wl18xx_driver_init


module_platform_driver(wl18xx_driver)


static int __init wl18xx_driver_init(void) {
return platform_driver_register(&(wl18xx_driver));
}
static initcall_t __initcall_wl18xx_driver_init6 __used __attribute__((__section__(".initcall" "6" ".init"))) = wl18xx_driver_init;
static void __exit wl18xx_driver_exit(void) {
platform_driver_unregister(&(wl18xx_driver));
}
static exitcall_t __exitcall_wl18xx_driver_exit __exit_call = wl18xx_driver_exit;



See module_platform_driver macro and module driver macro.



@ It would be best to post some source code or links the next time, it would make it easier. Including kernel version would be also a good idea.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift