linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Test: Driver: Hello World module accept command line argument
@ 2024-01-21 14:13 Vivek Yadav
  0 siblings, 0 replies; only message in thread
From: Vivek Yadav @ 2024-01-21 14:13 UTC (permalink / raw)
  To: skhan; +Cc: linux-kernel-mentees, Vivek Yadav

- 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


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

only message in thread, other threads:[~2024-01-21 14:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21 14:13 [PATCH] Test: Driver: Hello World module accept command line argument Vivek Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).