Added some comments about what our code do.
[cascardo/kernel/samples/01.hello/.git] / hello.c
1 /* Must be included by every module. */
2 #include <linux/module.h>
3
4 /* Should be declared to not taint the kernel. */
5 MODULE_LICENSE("GPL");
6
7 /* Our init function: returns 0 if successfull, an error code, otherwise. */
8 static int hello_init(void)
9 {
10         /* printk is just like printf, but without floating point support. */
11         printk(KERN_ALERT "Hello, world!\n");
12         return 0;
13 }
14
15 /* Our exit function: static is good, so we do not pollute namespace. */
16 static void hello_exit(void)
17 {
18         /* KERN_ALERT is a string macro prepended to our message. */
19         printk(KERN_ALERT "Goodbye, cruel world!\n");
20 }
21
22 /* Here, we declare our module init and exit functions. */
23 module_init(hello_init);
24 module_exit(hello_exit);