Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*                                                     
  2  * $Id: hellop.c,v 1.4 2004/09/26 07:02:43 gregkh Exp $ 
  3  */                                                    
  4 #include <linux/init.h>
  5 #include <linux/module.h>
  6 #include <linux/moduleparam.h>
  7 
  8 MODULE_LICENSE("Dual BSD/GPL");
  9 
 10 /*                                                        
 11  * These lines, although not shown in the book,           
 12  * are needed to make hello.c run properly even when      
 13  * your kernel has version support enabled                
 14  */                                                       
 15                                                           
 16 
 17 /*
 18  * A couple of parameters that can be passed in: how many times we say
 19  * hello, and to whom.
 20  */
 21 static char *whom = "world";
 22 static int howmany = 1;
 23 module_param(howmany, int, S_IRUGO);
 24 module_param(whom, charp, S_IRUGO);
 25 
 26 static int hello_init(void)
 27 {
 28         int i;
 29         for (i = 0; i < howmany; i++)
 30                 printk(KERN_ALERT "(%d) Hello, %s\n", i, whom);
 31         return 0;
 32 }
 33 
 34 static void hello_exit(void)
 35 {
 36         printk(KERN_ALERT "Goodbye, cruel world\n");
 37 }
 38 
 39 module_init(hello_init);
 40 module_exit(hello_exit);
 41 
  This page was automatically generated by the LXR engine.