title: What is the difference between module_init and init_module in a Linux kernel module?
body: <p>I have been trying to port few linux drivers and realized that there is substantial difference between kernel version 2.4 and 2.6 of linux.</p>
  
  <p>In the 2.4 version of kernel, the module programming was as below -</p>
  
  <pre><code>#define MODULE
  #include &lt;linux/module.h&gt;
  #include &lt;linux/kernel.h&gt;
  
  int init_module(void)      
  { 
  printk(KERN_INFO "Hi \n"); 
  return 0; 
  }
  
  void cleanup_module(void)  
  { 
  printk(KERN_INFO "Bye \n"); 
  }
  </code></pre>
  
  <p>But, with the 2.6 version of kernel, the following has to be done for modules -</p>
  
  <pre><code>#include &lt;linux/init.h&gt;
  #include &lt;linux/module.h&gt;
  #include &lt;linux/kernel.h&gt;
  
  static int hi_init(void)
  {
      printk(KERN_ALERT "Hi \n");
      return 0;
  }
  
  static void hi_exit(void)
  {
      printk(KERN_ALERT "Bye \n");
  }
  
  module_init(hi_init);
  module_exit(hi_exit);
  </code></pre>
  
  <p>What is the advantage of such changes in Kernel 2.6 and Why was that change required in kernel 2.6 of linux ?</p>