Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
From f376831f690d3907c26acf20f2829c6a83ec8437 Mon Sep 17 00:00:00 2001
From: "Felipe F. Tonello" <eu@felipetonello.com>
Date: Wed, 2 Dec 2015 15:32:47 +0000
Subject: [PATCH] blog: hello-world.c
Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
drivers/Kconfig | 2 ++
drivers/Makefile | 1 +
drivers/hello/Kconfig | 5 +++++
drivers/hello/Makefile | 1 +
drivers/hello/hello-world.c | 19 +++++++++++++++++++
5 files changed, 28 insertions(+)
create mode 100644 drivers/hello/Kconfig
create mode 100644 drivers/hello/Makefile
create mode 100644 drivers/hello/hello-world.c
diff --git a/drivers/Kconfig b/drivers/Kconfig
index d2ac339..5555c56 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -198,4 +198,6 @@ source "drivers/hwtracing/intel_th/Kconfig"
source "drivers/fpga/Kconfig"
+source "drivers/hello/Kconfig"
+
endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 795d0ca..589543d 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -172,3 +172,4 @@ obj-$(CONFIG_STM) += hwtracing/stm/
obj-$(CONFIG_ANDROID) += android/
obj-$(CONFIG_NVMEM) += nvmem/
obj-$(CONFIG_FPGA) += fpga/
+obj-$(CONFIG_HELLOWORLD) += hello/
diff --git a/drivers/hello/Kconfig b/drivers/hello/Kconfig
new file mode 100644
index 0000000..43ef5f3
--- /dev/null
+++ b/drivers/hello/Kconfig
@@ -0,0 +1,5 @@
+config HELLOWORLD
+ tristate "Hello, World! module"
+ help
+ Hello, World! This is a description of this configuration. This
+ configuration enables the compilation of the Hello, World! module.
diff --git a/drivers/hello/Makefile b/drivers/hello/Makefile
new file mode 100644
index 0000000..961d629
--- /dev/null
+++ b/drivers/hello/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_HELLOWORLD) += hello-world.o
diff --git a/drivers/hello/hello-world.c b/drivers/hello/hello-world.c
new file mode 100644
index 0000000..19b95d9
--- /dev/null
+++ b/drivers/hello/hello-world.c
@@ -0,0 +1,19 @@
+#include <linux/init.h> /* Used for module_init/exit() macros */
+#include <linux/kernel.h> /* Define KERN_ERR */
+#include <linux/module.h> /* Used for all modules */
+
+static int __init hello_init(void)
+{
+ printk(KERN_ERR "################# Hello, World!\n");
+ return 0;
+}
+
+static void __exit hello_exit(void)
+{
+ printk(KERN_ERR "################# Goodbye, World ....\n");
+}
+
+module_init(hello_init);
+module_exit(hello_exit);
+
+MODULE_LICENSE("GPL v2");
--
2.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.