Linux Kernel Mentees list
 help / color / mirror / Atom feed
From: Vivek Yadav <vivekyadav1207731111@gmail.com>
To: skhan@linuxfoundation.org
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
	Vivek Yadav <vivekyadav1207731111@gmail.com>
Subject: [PATCH] Test: Driver: Hello World module accept command line argument
Date: Sun, 21 Jan 2024 19:43:54 +0530	[thread overview]
Message-ID: <20240121141354.75893-1-vivekyadav1207731111@gmail.com> (raw)

- This module accept command line argument as string and print
them as well in dmesg.

Signed-off-by: Vivek Yadav <vivekyadav1207731111@gmail.com>
---
 drivers/HelloWorld/HelloWorld-2.c | 37 +++++++++++++++++++++++++++++++
 drivers/HelloWorld/Kconfig        |  1 -
 drivers/HelloWorld/Makefile       |  2 +-
 3 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 drivers/HelloWorld/HelloWorld-2.c

diff --git a/drivers/HelloWorld/HelloWorld-2.c b/drivers/HelloWorld/HelloWorld-2.c
new file mode 100644
index 000000000000..4b2661fab6b1
--- /dev/null
+++ b/drivers/HelloWorld/HelloWorld-2.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+/* This is test file for Linux kernel module
+ * Here I have written a simple Hello World module
+ *
+ * author : Vivek Yadav
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/moduleparam.h>
+
+char *cmd_param = " ";
+int count;
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Vivek Yadav");
+MODULE_DESCRIPTION("Simple Hello World Kernel Module with command line parameters");
+
+module_param(cmd_param, charp, 0644);
+module_param(count, int, 0);
+
+static int __init hello_init_module(void)
+{
+	pr_info("Hello World 2.\n");
+	pr_info("cmd_param = %s\n", cmd_param);
+	pr_info("string count = %d\n", count);
+	return 0;
+}
+
+static void __exit hello_cleanup_module(void)
+{
+	pr_info("Goodbye World 2.\n");
+}
+
+module_init(hello_init_module);
+module_exit(hello_cleanup_module);
diff --git a/drivers/HelloWorld/Kconfig b/drivers/HelloWorld/Kconfig
index 27606645f577..eed8a6c7c40d 100644
--- a/drivers/HelloWorld/Kconfig
+++ b/drivers/HelloWorld/Kconfig
@@ -1,5 +1,4 @@
 menu "Hello Module Kernel Support"
-​
 config HELLO_WORLD
         tristate "Hello Module Driver"
         depends on X86
diff --git a/drivers/HelloWorld/Makefile b/drivers/HelloWorld/Makefile
index 03c1da296446..8ffb53ac21e7 100644
--- a/drivers/HelloWorld/Makefile
+++ b/drivers/HelloWorld/Makefile
@@ -1 +1 @@
-obj-$(CONFIG_HELLO_WORLD)	+= HelloWorld-1.o
+obj-$(CONFIG_HELLO_WORLD)	+= HelloWorld-1.o HelloWorld-2.o
-- 
2.34.1


                 reply	other threads:[~2024-01-21 14:14 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=20240121141354.75893-1-vivekyadav1207731111@gmail.com \
    --to=vivekyadav1207731111@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