world leader in high performance signal processing
Trace: » init

Kernel Module init

The module_init() and module_exit() macros are used to define the entry and exit points of the modules.

Note that the module_init() function must return 0 to indicate that the module HAS loaded.

Here is a code example:

 
  #include <linux/init.h>                        
  #include <linux/module.h>                      
  #include <linux/kernel.h>  
 
 // simply use the kernel printk function
 // on module init and exit                                               
 
static int __init mymod_init(void) {           
      printk(KERN_INFO "Hello, my module\n");    
      return 0;                                  
}                                              
 
static void __exit mymod_exit(void) {          
      printk(KERN_INFO "Goodbye my module\n");   
}                                              
 //                                              
 // this is correct                              
 //                                              
module_init(mymod_init);                       
module_exit(mymod_exit);                       
//                                              
// Add this to stop the tainted message on dumps
MODULE_LICENSE("GPL")                          
//