772a1e37219996c018bc20cdcf7cfe6b5fc99dd8
[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 #ifndef SUBJECT
8 #define SUBJECT "world"
9 #endif
10
11 /* Our init function: returns 0 if successfull, an error code, otherwise. */
12 static int hello_init(void)
13 {
14         /* printk is just like printf, but without floating point support. */
15         printk(KERN_ALERT "Hello, " SUBJECT "!\n");
16         return 0;
17 }
18
19 /* Our exit function: static is good, so we do not pollute namespace. */
20 static void hello_exit(void)
21 {
22         /* KERN_ALERT is a string macro prepended to our message. */
23         printk(KERN_ALERT "Goodbye, cruel " SUBJECT "!\n");
24 }
25
26 /* Here, we declare our module init and exit functions. */
27 module_init(hello_init);
28 module_exit(hello_exit);