Skip to contentSkip to conversation

hello-mod/hello.c: convert to module_init/module_exit

PATCH In review Trevor Woerner 3 participants 6 messages Sep 15, 2021 – Sep 27, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hello-mod/hello.c: convert to module_init/module_exit

Switch away from the old init_module/cleanup_module function names for the main entry points. Change them to the documented method with module_init() and module_exit() markers next to static functions.

---
 meta-skeleton/recipes-kernel/hello-mod/files/hello.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta-skeleton/recipes-kernel/hello-mod/files/hello.c +4 -2
index f3c0d372eb..b68b0c348e 100644
@@ -19,15 +19,17 @@
 
 #include <linux/module.h>
 
-int init_module(void)
+static int __init hello_init(void)
 {
 	printk("Hello World!\n");
 	return 0;
 }
 
-void cleanup_module(void)
+static void __exit hello_exit(void)
 {
 	printk("Goodbye Cruel World!\n");
 }
 
+module_init(hello_init);
+module_exit(hello_exit);
 MODULE_LICENSE("GPL");
Signature · 1 line
2.30.0.rc0
#1 lore raw

PATCH 2/2 hello-mod/hello.c: convert printk to pr_xxx

Convert to the newer pr_xxx aliases for logging, which embed the log level in the macro names.

---
 meta-skeleton/recipes-kernel/hello-mod/files/hello.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta-skeleton/recipes-kernel/hello-mod/files/hello.c +2 -2
index b68b0c348e..6b73a79524 100644
@@ -21,13 +21,13 @@
 
 static int __init hello_init(void)
 {
-	printk("Hello World!\n");
+	pr_info("Hello World!\n");
 	return 0;
 }
 
 static void __exit hello_exit(void)
 {
-	printk("Goodbye Cruel World!\n");
+	pr_info("Goodbye Cruel World!\n");
 }
 
 module_init(hello_init);
Signature · 1 line
2.30.0.rc0
#3 lore raw

Re: [OE-core] [meta-skeleton][PATCH 2/2] hello-mod/hello.c: convert printk to pr_xxx

ping?

It seems 1/2 got applied, but I didn't see an NAKs for 2/2?

Quoted 14 lines · Quentin Schulz

Hi Trevor,

Quoted 1 line · Trevor Woerner

Convert to the newer pr_xxx aliases for logging, which embed the log

level in

Quoted 3 lines

the macro names.

Thanks!
Quentin

#4 lore raw

Re: [OE-core] [meta-skeleton][PATCH 2/2] hello-mod/hello.c: convert printk to pr_xxx

Quoted 3 lines · Trevor Woerner

ping?

It seems 1/2 got applied, but I didn't see an NAKs for 2/2?

My intention was to apply both, not sure what happened, sorry. I've queued it.

Cheers,

Richard