* Q: generic module{init,exit} boilerplate
@ 2013-01-10 17:12 H Hartley Sweeten
2013-01-10 18:41 ` Dan Carpenter
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: H Hartley Sweeten @ 2013-01-10 17:12 UTC (permalink / raw)
To: kernel-janitors
Hello all,
There are a number of drivers/modules in the kernel that have
a "do nothing" module init/exit of the form:
static int __init foo_init(void)
{
return 0;
}
module_init(foo_init);
static void __exit foo_exit(void)
{
}
module_exit(foo_exit);
Is it worth creating a generic helper macro to handle this boilerplate?
Something along the lines of the module_driver() macro. Each use would
replace about 10 lines-of-code with a single line.
If so what would be a good name for the macro and what header would
be the appropriate place for it to reside?
Thanks for any replies!
Hartley
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Q: generic module{init,exit} boilerplate
2013-01-10 17:12 Q: generic module{init,exit} boilerplate H Hartley Sweeten
@ 2013-01-10 18:41 ` Dan Carpenter
2013-01-10 18:58 ` Julia Lawall
2013-01-10 19:05 ` H Hartley Sweeten
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2013-01-10 18:41 UTC (permalink / raw)
To: kernel-janitors
On Thu, Jan 10, 2013 at 11:12:43AM -0600, H Hartley Sweeten wrote:
> Hello all,
>
> There are a number of drivers/modules in the kernel that have
> a "do nothing" module init/exit of the form:
>
Do you have a real life example? Why would people do that?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Q: generic module{init,exit} boilerplate
2013-01-10 17:12 Q: generic module{init,exit} boilerplate H Hartley Sweeten
2013-01-10 18:41 ` Dan Carpenter
@ 2013-01-10 18:58 ` Julia Lawall
2013-01-10 19:05 ` H Hartley Sweeten
2 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2013-01-10 18:58 UTC (permalink / raw)
To: kernel-janitors
On Thu, 10 Jan 2013, Dan Carpenter wrote:
> On Thu, Jan 10, 2013 at 11:12:43AM -0600, H Hartley Sweeten wrote:
> > Hello all,
> >
> > There are a number of drivers/modules in the kernel that have
> > a "do nothing" module init/exit of the form:
> >
>
> Do you have a real life example? Why would people do that?
I find 39 occurrences, although the first one I looked at had a big #if 0
in the module_init function. Here are some examples:
drivers/media/common/saa7146/saa7146_fops.c
drivers/media/platform/soc_camera/soc_mediabus.c
drivers/tty/serial/suncore.c
There are also a bunch of comedi drivers. Around half of the examples are
sound drivers, eg:
sound/synth/emux/emux.c
sound/synth/util_mem.c
sound/isa/sb/sb16_csp.c
julia
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Q: generic module{init,exit} boilerplate
2013-01-10 17:12 Q: generic module{init,exit} boilerplate H Hartley Sweeten
2013-01-10 18:41 ` Dan Carpenter
2013-01-10 18:58 ` Julia Lawall
@ 2013-01-10 19:05 ` H Hartley Sweeten
2 siblings, 0 replies; 4+ messages in thread
From: H Hartley Sweeten @ 2013-01-10 19:05 UTC (permalink / raw)
To: kernel-janitors
On Thursday, January 10, 2013 11:58 AM, Julia Lawall wrote:
> On Thu, 10 Jan 2013, Dan Carpenter wrote:
>
>> On Thu, Jan 10, 2013 at 11:12:43AM -0600, H Hartley Sweeten wrote:
>>> Hello all,
>>>
>>> There are a number of drivers/modules in the kernel that have
>>> a "do nothing" module init/exit of the form:
>>>
>>
>> Do you have a real life example? Why would people do that?
>
> I find 39 occurrences, although the first one I looked at had a big #if 0
> in the module_init function. Here are some examples:
>
> drivers/media/common/saa7146/saa7146_fops.c
> drivers/media/platform/soc_camera/soc_mediabus.c
> drivers/tty/serial/suncore.c
>
> There are also a bunch of comedi drivers. Around half of the examples are
> sound drivers, eg:
>
> sound/synth/emux/emux.c
> sound/synth/util_mem.c
> sound/isa/sb/sb16_csp.c
Most of them appear to be in modules that provide exported functions for
other drivers/modules. These modules do nothing by themselves so I guess
they have the do nothing module_{init,exit} just because it's required since
they can be modules.
That brings up the question...
Do these types of helper modules actually require the module_{init,exit}?
Would the module load properly without it? They don't _do_ anything other
than EXPORT a number of symbols for other modules.
Regards,
Hartley
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-10 19:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10 17:12 Q: generic module{init,exit} boilerplate H Hartley Sweeten
2013-01-10 18:41 ` Dan Carpenter
2013-01-10 18:58 ` Julia Lawall
2013-01-10 19:05 ` H Hartley Sweeten
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox