aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/04/coding_style.c
diff options
context:
space:
mode:
authorBryan Brattlof <hello@bryanbrattlof.com>2020-07-15 12:59:57 -0400
committerBryan Brattlof <hello@bryanbrattlof.com>2020-07-15 12:59:57 -0400
commitba717131952f892d88459a265915563796683347 (patch)
tree9d4cef9b4dfb93a897044149a6a15b72340d0460 /tasks/04/coding_style.c
parentcecd3facfa6b2be63b04232ea055a589c8dc406b (diff)
downloadeudyptula-challenge-ba717131952f892d88459a265915563796683347.tar.gz
eudyptula-challenge-ba717131952f892d88459a265915563796683347.tar.bz2
task 4: add task readme
Diffstat (limited to 'tasks/04/coding_style.c')
-rw-r--r--tasks/04/coding_style.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tasks/04/coding_style.c b/tasks/04/coding_style.c
new file mode 100644
index 0000000..cebe4e5
--- /dev/null
+++ b/tasks/04/coding_style.c
@@ -0,0 +1,35 @@
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+int do_work(int *my_int, int retval)
+{
+ int x;
+ int y = *my_int;
+ int z;
+
+ for(x = 0 ; x < *my_int ; ++x)
+ udelay(10);
+ if (y < 10)
+ /* That was a long sleep, tell userspace about it. */
+ pr_debug("We slept a long time!");
+ z = x * y;
+
+ return z;
+}
+
+int my_init(void)
+{
+ int x = 10;
+
+ x = do_work(&x, x);
+
+ return x;
+}
+
+void my_exit(void)
+{
+}
+
+module_init(my_init);
+module_exit(my_exit);