Skip to contentSkip to conversation

Test: Driver: Hello World module

PATCH New Vivek Yadav 1 participant 1 message Jan 20, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Test: Driver: Hello World module

From: Vivek <[email protected]>

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

---
 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
drivers/HelloWorld/HelloWorld-1.c new file +27 -0
new file mode 100644
index 000000000000..3dd1c32c9ec6
@@ -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");
drivers/HelloWorld/Kconfig new file +9 -0
new file mode 100644
index 000000000000..27606645f577
@@ -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
drivers/HelloWorld/Makefile new file +1 -0
new file mode 100644
index 000000000000..03c1da296446
@@ -0,0 +1 @@
+obj-$(CONFIG_HELLO_WORLD)	+= HelloWorld-1.o
drivers/Kconfig +2 -0
index 7bdad836fc62..509ecadffa26 100644
@@ -245,4 +245,6 @@ source "drivers/cdx/Kconfig"
 
 source "drivers/dpll/Kconfig"
 
+source "drivers/HelloWorld/Kconfig"
+
 endmenu
drivers/Makefile +2 -0
index 37fd6ce3bd7f..13f26fa34fc7 100644
@@ -198,3 +198,5 @@ obj-$(CONFIG_CDX_BUS)		+= cdx/
 obj-$(CONFIG_DPLL)		+= dpll/
 
 obj-$(CONFIG_S390)		+= s390/
+
+obj-$(CONFIG_HELLO_WORLD)	+= HelloWorld/
Signature · 1 line
2.34.1