From: Sumya Hoque <sumyahoque2012@gmail.com>
To: skhan@linuxfoundation.org
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
Sumya Hoque <sumyahoque2012@gmail.com>
Subject: [PATCH] Added module params and fixed checkpath errors
Date: Wed, 12 Feb 2025 05:35:05 +0000 [thread overview]
Message-ID: <20250212053505.10129-1-sumyahoque2012@gmail.com> (raw)
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
reply other threads:[~2025-02-12 5:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250212053505.10129-1-sumyahoque2012@gmail.com \
--to=sumyahoque2012@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox