public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] Added module params and fixed checkpath errors
@ 2025-02-12  5:35 Sumya Hoque
  0 siblings, 0 replies; only message in thread
From: Sumya Hoque @ 2025-02-12  5:35 UTC (permalink / raw)
  To: skhan; +Cc: linux-kernel-mentees, Sumya Hoque

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

Signed-off-by: Sumya Hoque <sumyahoque2012@gmail.com>
---
 linux_custom_modules/hello.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/linux_custom_modules/hello.c b/linux_custom_modules/hello.c
index 178b717e1de1..b60c7b5f6ee9 100644
--- a/linux_custom_modules/hello.c
+++ b/linux_custom_modules/hello.c
@@ -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");
-
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-12  5:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12  5:35 [PATCH] Added module params and fixed checkpath errors Sumya Hoque

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox