Skip to contentSkip to conversation

Added module params and fixed checkpath errors

PATCH New Sumya Hoque 1 participant 1 message Feb 12, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added module params and fixed checkpath errors

I’ve followed these steps to add module parameters and capture the dmesg output:

I included the module.h header and used the module_param() macro to take the argument value as input from the command line. At runtime, insmod will take the input for the "name" variable. The default value is "World" if no input is provided.

Dmesg Output:

[32002.988222] Removing module... Goodbye World!
[32026.041939] Loading module... Hello Sumya
---
 linux_custom_modules/hello.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
linux_custom_modules/hello.c +5 -7
index 178b717e1de1..b60c7b5f6ee9 100644
@@ -1,18 +1,17 @@
 #include <linux/module.h>
 #include <linux/printk.h>
 #include <linux/kernel.h>
-char *name = "World";
-module_param(name, charp, 0000);
+char *my_name = "World";
+module_param(my_name, charp, 0000);
 int hello(void)
 {
-        printk(KERN_INFO "Loading module... Hello %s\n", name);
-
-        return 0;
+	printk(KERN_INFO "Loading module... Hello %s\n", my_name);
+	return 0;
 }
 
 void goodbye(void)
 {
-        printk(KERN_INFO "Removing module... Goodbye World!\n");
+	printk(KERN_INFO "Removing module... Goodbye World!\n");
 }
 
 module_init(hello);
@@ -20,4 +19,3 @@ module_exit(goodbye);
 MODULE_DESCRIPTION("A basic Hello World module");
 MODULE_AUTHOR("sumya");
 MODULE_LICENSE("GPL");
-
Signature · 1 line
2.34.1