* Correct use of __init and __devinit
@ 2007-12-23 16:56 Adrian McMenamin
2007-12-24 13:01 ` Sam Ravnborg
0 siblings, 1 reply; 3+ messages in thread
From: Adrian McMenamin @ 2007-12-23 16:56 UTC (permalink / raw)
To: linux-kernel
Could someone here help settle this argument?
I have written a driver (for the CD Rom on the Sega Dreamcast). I have
marked various initialisation functions - including probe() and the
functions that it, and only it, calls, as __init.
Other developers tell me I should mark them as __devinit.
However I think this is wrong as:
* The CD on the Dreamcast is not and will never be a hotpluggable device
* The Dreamcast is a limited memory device and if marking various
functions as __init helps save memory that is A Good Thing
It has been put to me that while the use case (not hotpluggable) is
correct, it is still better practice to use __devinit
I have built the code with both __init and __devinit and both work, so
there is no issue of practicality as such here.
Adrian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Correct use of __init and __devinit
2007-12-23 16:56 Correct use of __init and __devinit Adrian McMenamin
@ 2007-12-24 13:01 ` Sam Ravnborg
2007-12-26 22:50 ` Haavard Skinnemoen
0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2007-12-24 13:01 UTC (permalink / raw)
To: Adrian McMenamin; +Cc: linux-kernel
On Sun, Dec 23, 2007 at 04:56:14PM +0000, Adrian McMenamin wrote:
> Could someone here help settle this argument?
>
> I have written a driver (for the CD Rom on the Sega Dreamcast). I have
> marked various initialisation functions - including probe() and the
> functions that it, and only it, calls, as __init.
>
> Other developers tell me I should mark them as __devinit.
>
> However I think this is wrong as:
>
> * The CD on the Dreamcast is not and will never be a hotpluggable device
>
> * The Dreamcast is a limited memory device and if marking various
> functions as __init helps save memory that is A Good Thing
>
> It has been put to me that while the use case (not hotpluggable) is
> correct, it is still better practice to use __devinit
If you use the register* functions of the driver model then
you are no longer in 100% control when your functions are
called.
So of the principle of least suprise it is best to use __devinit
for the probe function as most other drivers do. And if
the driver model happens to call your probe function after
init time then we will not oops.
So wit other words - use same pattern a other drivers and accept
that we could have saved a few hundred bytes extra but we do not do so.
Sam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Correct use of __init and __devinit
2007-12-24 13:01 ` Sam Ravnborg
@ 2007-12-26 22:50 ` Haavard Skinnemoen
0 siblings, 0 replies; 3+ messages in thread
From: Haavard Skinnemoen @ 2007-12-26 22:50 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: Adrian McMenamin, linux-kernel
On Mon, 24 Dec 2007 14:01:43 +0100
Sam Ravnborg <sam@ravnborg.org> wrote:
> So of the principle of least suprise it is best to use __devinit
> for the probe function as most other drivers do. And if
> the driver model happens to call your probe function after
> init time then we will not oops.
If you're dealing with platform_devices, you can use
platform_driver_probe() and remove the probe() function from the
platform_driver struct to ensure this never happens.
This is only ok for non-hotpluggable devices, of course.
Haavard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-12-26 22:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-23 16:56 Correct use of __init and __devinit Adrian McMenamin
2007-12-24 13:01 ` Sam Ravnborg
2007-12-26 22:50 ` Haavard Skinnemoen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox