What is __init?

Prabhu nath gprabhunath at gmail.com
Mon Feb 7 01:52:33 EST 2011


__init is a qualifier to a function or initialized data and a hint to the
linker to place all these
code and data in a seperate section in the object file, so that once these
functions are executed, memory space occupied by these code and data will be
freed.

It is the onus on the Kernel programmer to decide which functions/data to be
marked as __init.
For Eg. the init functions of a driver module, in most cases will be
executed only once and no other functions will invoke this init function.
Thus, init function will be the right candidate to be marked as __init.

http://lxr.linux.no/#linux+v2.6.37/include/linux/init.h

Regards,
Prabhu


On Mon, Feb 7, 2011 at 12:11 PM, Joy Sun <joy2sun127 at gmail.com> wrote:

> Hi,
>
> I am totally newbie for kernel device driver, and starting to learn.
>
> When I see a driver code, I found __init. For example, static int __init
> xxxx(struct platform_device *pdev)
>
> I understand "static" and "int", but what is __init?
>
> -J.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110207/7d74f70f/attachment.html 


More information about the Kernelnewbies mailing list