public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
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 parameters to the hello modlue
Date: Wed, 12 Feb 2025 04:40:20 +0000	[thread overview]
Message-ID: <20250212044020.9095-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: 

[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


                 reply	other threads:[~2025-02-12  4:40 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=20250212044020.9095-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