aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/04/coding_style.c
diff options
context:
space:
mode:
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);