[FE training-materials-updates] Code examples mentioned in the slides
michael.opdenacker at free-electrons.com
michael.opdenacker at free-electrons.com
Tue Mar 20 21:48:52 CET 2012
- Log -----------------------------------------------------------------
http://git.free-electrons.com/training-materials/commit/?id=1e78c00f3ae580b01376297d02897ca4c2dbfc49
commit 1e78c00f3ae580b01376297d02897ca4c2dbfc49
Author: Michael Opdenacker <michael.opdenacker at free-electrons.com>
Date: Tue Mar 20 21:46:46 2012 +0100
Code examples mentioned in the slides
Tested with 3.0
diff --git a/code/hello/Makefile b/code/hello/Makefile
new file mode 100644
index 0000000..f2b5908
--- /dev/null
+++ b/code/hello/Makefile
@@ -0,0 +1,7 @@
+obj-m := hello.o
+
+KDIR := /lib/modules/`uname -r`/build
+PWD := $(shell pwd)
+
+default:
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
diff --git a/code/hello/hello.c b/code/hello/hello.c
new file mode 100644
index 0000000..919231d
--- /dev/null
+++ b/code/hello/hello.c
@@ -0,0 +1,23 @@
+/* hello.c */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+static int __init hello_init(void)
+{
+ pr_alert("Good morrow");
+ pr_alert("to this fair assembly.\n");
+ return 0;
+}
+
+static void __exit hello_exit(void)
+{
+ pr_alert("Alas, poor world, what treasure");
+ pr_alert("hast thou lost!\n");
+}
+
+module_init(hello_init);
+module_exit(hello_exit);
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Greeting module");
+MODULE_AUTHOR("William Shakespeare");
-----------------------------------------------------------------------
Summary of changes:
code/hello/Makefile | 7 +++++++
code/hello/hello.c | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
create mode 100644 code/hello/Makefile
create mode 100644 code/hello/hello.c
More information about the training-materials-updates
mailing list