diff options
author | Javier Martinez Canillas <martinez.javier@gmail.com> | 2010-11-27 07:49:17 +0100 |
---|---|---|
committer | Javier Martinez Canillas <martinez.javier@gmail.com> | 2010-11-27 07:49:17 +0100 |
commit | ab121f379a3cff458c90e6f480ba4bb68c8733dd (patch) | |
tree | a9851af109ee83646d108bc247d03b131461b764 /misc-modules/hellop.c | |
download | ldd3-ab121f379a3cff458c90e6f480ba4bb68c8733dd.tar.gz |
Linux Device Drivers 3 examples
Diffstat (limited to 'misc-modules/hellop.c')
-rw-r--r-- | misc-modules/hellop.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/misc-modules/hellop.c b/misc-modules/hellop.c new file mode 100644 index 0000000..88eaa67 --- /dev/null +++ b/misc-modules/hellop.c @@ -0,0 +1,40 @@ +/* + * $Id: hellop.c,v 1.4 2004/09/26 07:02:43 gregkh Exp $ + */ +#include <linux/init.h> +#include <linux/module.h> +#include <linux/moduleparam.h> + +MODULE_LICENSE("Dual BSD/GPL"); + +/* + * These lines, although not shown in the book, + * are needed to make hello.c run properly even when + * your kernel has version support enabled + */ + + +/* + * A couple of parameters that can be passed in: how many times we say + * hello, and to whom. + */ +static char *whom = "world"; +static int howmany = 1; +module_param(howmany, int, S_IRUGO); +module_param(whom, charp, S_IRUGO); + +static int hello_init(void) +{ + int i; + for (i = 0; i < howmany; i++) + printk(KERN_ALERT "(%d) Hello, %s\n", i, whom); + return 0; +} + +static void hello_exit(void) +{ + printk(KERN_ALERT "Goodbye, cruel world\n"); +} + +module_init(hello_init); +module_exit(hello_exit); |