The main difference is freeing of memory .
The__init token
in the it is a hint to the kernel that the givenfunction is used only at initialization time.
The module loader drops the initialization function after the module is loaded, making its memory available for other uses.
There is a similar tag (__initdata)for data used only during initialization. Use of __init and __initdata is optional, but it is worth the trouble. Just be sure not to use them for
any function (or data structure)you will be using after initialization completes.
use of the __init family of
macros to place one-time initialization routines into a common section in the object file.
Its cousin
__initdata , used to mark one-time-use data items . Functions and
data marked as initialization using these macros are collected into a specially named ELF section.
Later, after these one-time initialization functions and data objects have been used, the kernel frees
the memory occupied by these items
. You might have seen the familiar kernel message near the final
part of the boot process saying, "Freeing init memory: 296K." .
The purpose of placing
this function into a special section of the object file is so the memory space that it occupies can be
reclaimed when it is no longer needed.