[FE training-materials-updates] Added new example

michael.opdenacker at free-electrons.com michael.opdenacker at free-electrons.com
Tue Mar 20 22:04:25 CET 2012


- Log -----------------------------------------------------------------
http://git.free-electrons.com/training-materials/commit/?id=7469ed7a30b92e1b421ea86e196a22534f9e2a41

commit 7469ed7a30b92e1b421ea86e196a22534f9e2a41
Author: Michael Opdenacker <michael.opdenacker at free-electrons.com>
Date:   Tue Mar 20 22:03:42 2012 +0100

    Added new example

diff --git a/code/.gitignore b/code/.gitignore
new file mode 100644
index 0000000..9032caf
--- /dev/null
+++ b/code/.gitignore
@@ -0,0 +1,21 @@
+#
+# NOTE! Don't add files that are generated in specific
+# subdirectories here. Add them in the ".gitignore" file
+# in that subdirectory instead.
+#
+# NOTE! Please use 'git ls-files -i --exclude-standard'
+# command after changing this file, to see if there are
+# any tracked files which get ignored after the change.
+#
+# Normal rules
+#
+.*
+*.o
+*.o.*
+*.a
+*.ko
+*.mod.c
+Module.symvers
+!.gitignore
+*~
+modules.order
diff --git a/code/hello-param/Makefile b/code/hello-param/Makefile
new file mode 100644
index 0000000..d85d8a1
--- /dev/null
+++ b/code/hello-param/Makefile
@@ -0,0 +1,7 @@
+obj-m := hello_param.o
+
+KDIR := /lib/modules/`uname -r`/build 
+PWD := $(shell pwd)
+
+default:
+	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
diff --git a/code/hello-param/hello_param.c b/code/hello-param/hello_param.c
new file mode 100644
index 0000000..60304df
--- /dev/null
+++ b/code/hello-param/hello_param.c
@@ -0,0 +1,30 @@
+/* hello_param.c */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+
+MODULE_LICENSE("GPL");
+
+/* A couple of parameters that can be passed in: how many times we say
+   hello, and to whom */
+
+static char *whom = "world";
+module_param(whom, charp, 0);
+static int howmany = 1;
+module_param(howmany, int, 0);
+
+static int __init hello_init(void)
+{
+    int i;
+    for (i = 0; i < howmany; i++)
+    	pr_debug(KERN_ALERT "(%d) Hello, %s\n", i, whom);
+    return 0;
+}
+
+static void __exit hello_exit(void)
+{
+    pr_debug(KERN_ALERT "Goodbye, cruel %s\n", whom);
+}
+
+module_init(hello_init);
+module_exit(hello_exit);

-----------------------------------------------------------------------

Summary of changes:
 code/.gitignore                      |   21 +++++++++++++++++++++
 code/{hello => hello-param}/Makefile |    2 +-
 code/hello-param/hello_param.c       |   30 ++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletions(-)
 create mode 100644 code/.gitignore
 copy code/{hello => hello-param}/Makefile (83%)
 create mode 100644 code/hello-param/hello_param.c


More information about the training-materials-updates mailing list