forked from sysprog21/lkmpg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_tasklet.c
44 lines (37 loc) · 976 Bytes
/
example_tasklet.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* example_tasklet.c
*/
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
/* Macro DECLARE_TASKLET_OLD exists for compatibility.
* See https://lwn.net/Articles/830964/
*/
#ifndef DECLARE_TASKLET_OLD
#define DECLARE_TASKLET_OLD(arg1, arg2) DECLARE_TASKLET(arg1, arg2, 0L)
#endif
static void tasklet_fn(unsigned long data)
{
pr_info("Example tasklet starts\n");
mdelay(5000);
pr_info("Example tasklet ends\n");
}
static DECLARE_TASKLET_OLD(mytask, tasklet_fn);
static int example_tasklet_init(void)
{
pr_info("tasklet example init\n");
tasklet_schedule(&mytask);
mdelay(200);
pr_info("Example tasklet init continues...\n");
return 0;
}
static void example_tasklet_exit(void)
{
pr_info("tasklet example exit\n");
tasklet_kill(&mytask);
}
module_init(example_tasklet_init);
module_exit(example_tasklet_exit);
MODULE_DESCRIPTION("Tasklet example");
MODULE_LICENSE("GPL");