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

From: Vivek <vivekyadav1207731111@gmail.com>

- Hello World module added with Kconfig and Makefile
Also check with `make menuconfig`.

Signed-off-by: Vivek <vivekyadav1207731111@gmail.com>
---
 drivers/HelloWorld/HelloWorld-1.c | 27 +++++++++++++++++++++++++++
 drivers/HelloWorld/Kconfig        |  9 +++++++++
 drivers/HelloWorld/Makefile       |  1 +
 drivers/Kconfig                   |  2 ++
 drivers/Makefile                  |  2 ++
 5 files changed, 41 insertions(+)
 create mode 100644 drivers/HelloWorld/HelloWorld-1.c
 create mode 100644 drivers/HelloWorld/Kconfig
 create mode 100644 drivers/HelloWorld/Makefile

diff --git a/drivers/HelloWorld/HelloWorld-1.c b/drivers/HelloWorld/HelloWorld-1.c
new file mode 100644
index 000000000000..3dd1c32c9ec6
--- /dev/null
+++ b/drivers/HelloWorld/HelloWorld-1.c
@@ -0,0 +1,27 @@
+// 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/module.h>
+#include <linux/kernel.h>
+
+static int __init hello_init_module(void)
+{
+	pr_info("Hello World 1.\n");
+	return 0;
+}
+
+static void __exit hello_cleanup_module(void)
+{
+	pr_info("Goodbye World 1.\n");
+}
+
+module_init(hello_init_module);
+module_exit(hello_cleanup_module);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Vivek Yadav");
+MODULE_DESCRIPTION("Simple Hello World Kernel Module");
diff --git a/drivers/HelloWorld/Kconfig b/drivers/HelloWorld/Kconfig
new file mode 100644
index 000000000000..27606645f577
--- /dev/null
+++ b/drivers/HelloWorld/Kconfig
@@ -0,0 +1,9 @@
+menu "Hello Module Kernel Support"
+​
+config HELLO_WORLD
+        tristate "Hello Module Driver"
+        depends on X86
+        help
+		Select this option to run a Hello World Module!
+		It is just simple driver for testing.
+endmenu
diff --git a/drivers/HelloWorld/Makefile b/drivers/HelloWorld/Makefile
new file mode 100644
index 000000000000..03c1da296446
--- /dev/null
+++ b/drivers/HelloWorld/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_HELLO_WORLD)	+= HelloWorld-1.o
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 7bdad836fc62..509ecadffa26 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -245,4 +245,6 @@ source "drivers/cdx/Kconfig"
 
 source "drivers/dpll/Kconfig"
 
+source "drivers/HelloWorld/Kconfig"
+
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 37fd6ce3bd7f..13f26fa34fc7 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -198,3 +198,5 @@ obj-$(CONFIG_CDX_BUS)		+= cdx/
 obj-$(CONFIG_DPLL)		+= dpll/
 
 obj-$(CONFIG_S390)		+= s390/
+
+obj-$(CONFIG_HELLO_WORLD)	+= HelloWorld/
-- 
2.34.1


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

only message in thread, other threads:[~2024-01-20 17:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-20 17:50 [PATCH 2/2] Test: Driver: Hello World module 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).