* [PATCH] Added module parameters to the hello modlue
@ 2025-02-12 4:40 Sumya Hoque
0 siblings, 0 replies; only message in thread
From: Sumya Hoque @ 2025-02-12 4:40 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:
[27901.755598] Removing module... Goodbye World!
[27978.985148] Loading module... Hello Sumya
Signed-off-by: Sumya Hoque <sumyahoque2012@gmail.com>
---
linux_custom_modules/hello.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/linux_custom_modules/hello.c b/linux_custom_modules/hello.c
index a05727d605e3..178b717e1de1 100644
--- a/linux_custom_modules/hello.c
+++ b/linux_custom_modules/hello.c
@@ -1,8 +1,11 @@
#include <linux/module.h>
#include <linux/printk.h>
+#include <linux/kernel.h>
+char *name = "World";
+module_param(name, charp, 0000);
int hello(void)
{
- printk(KERN_INFO "Loading module... Hello World!\n");
+ printk(KERN_INFO "Loading module... Hello %s\n", name);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-02-12 4:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 4:40 [PATCH] Added module parameters to the hello modlue Sumya Hoque
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox