X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=hello.c;h=b5c0a6d6cd88104bf427aa3fd1b2ca7cd4d90d39;hb=refs%2Fheads%2Ftest;hp=772a1e37219996c018bc20cdcf7cfe6b5fc99dd8;hpb=3559c37d96b467dbd5abd5e9e6695e2fccb7958f;p=cascardo%2Fkernel%2Fsamples%2F01.hello%2F.git diff --git a/hello.c b/hello.c index 772a1e3..b5c0a6d 100644 --- a/hello.c +++ b/hello.c @@ -1,6 +1,12 @@ /* Must be included by every module. */ #include +/* Author name comes here. */ +MODULE_AUTHOR("Thadeu Lima de Souza Cascardo "); +/* Tell a user what this modules does. */ +MODULE_DESCRIPTION("Prints a friendly message."); +/* Which version is this? */ +MODULE_VERSION("1.4.0"); /* Should be declared to not taint the kernel. */ MODULE_LICENSE("GPL"); @@ -8,19 +14,26 @@ MODULE_LICENSE("GPL"); #define SUBJECT "world" #endif +static char *subject = SUBJECT; + +/* Define subject as a char pointer parameter. */ +module_param(subject, charp, 0664); +/* Parameter description. */ +MODULE_PARM_DESC(subject, "Subject to say hello to."); + /* Our init function: returns 0 if successfull, an error code, otherwise. */ -static int hello_init(void) +static int __init hello_init(void) { /* printk is just like printf, but without floating point support. */ - printk(KERN_ALERT "Hello, " SUBJECT "!\n"); + printk(KERN_ALERT "Hello, %s!\n", subject); return 0; } /* Our exit function: static is good, so we do not pollute namespace. */ -static void hello_exit(void) +static void __exit hello_exit(void) { /* KERN_ALERT is a string macro prepended to our message. */ - printk(KERN_ALERT "Goodbye, cruel " SUBJECT "!\n"); + printk(KERN_ALERT "Goodbye, cruel %s!\n", subject); } /* Here, we declare our module init and exit functions. */