forked from aakbar5/handy-kernel_modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasklet.c
49 lines (40 loc) · 945 Bytes
/
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
45
46
47
48
49
// An example of Tasklet
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
// Data to tasklet
static char tl_data[] = "Tasklet data";
// Callback for tasklet
static void tl_tasklet_func(unsigned long data) {
pr_info("tl_tasklet_func: %s\n", (char *)data);
}
// Tasklet
DECLARE_TASKLET(tl_tasklet, tl_tasklet_func, (unsigned long)tl_data);
//
// Module entry point
//
static int __init tl_init(void) {
pr_info("tl: init\n");
tasklet_schedule(&tl_tasklet);
return 0;
}
//
// Module exit point
//
static void __exit tl_exit(void) {
pr_info("tl: exit\n");
tasklet_kill(&tl_tasklet);
}
//
// Setup module entry and exit points
//
module_init(tl_init);
module_exit(tl_exit);
//
// Setup module info
//
MODULE_VERSION("0.0.1");
MODULE_DESCRIPTION("tl: Tasklet example");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("aakbar5 <16612387+aakbar5@users.noreply.github.com>");