parameter of module_init() and module_exit() must not be a macro

Greg KH greg at kroah.com
Thu Oct 15 09:55:22 EDT 2015


On Thu, Oct 15, 2015 at 09:48:53AM +0000, Warlich, Christof wrote:
> I'd just like to get some feedback on the following issue and if the patch that I'm suggesting would be appropriate to be considered for upstream submission:
> 
> While writing a driver template, I just came across an issue with the module_init() and module_exit() macros: They don't work properly when the parameter being passed to them is a macro itself. Here is a minimal example that shows the issue:
> 
> $ cat test.c
> #include <linux/module.h>
> #define DRIVER_INIT test_init
> static int __init DRIVER_INIT(void)
> {
> 	return 0;
> }
> //module_init(test_init); // This works, ...
> module_init(DRIVER_INIT); // ... but this doesn't.

I'll ask, why would you ever want to pass a macro to module_init()?

We don't like functions to be macros in the kernel, do you have a
real-world need for this somewhere?  If so, can you show the code?

thanks,

greg k-h



More information about the Kernelnewbies mailing list