forked from PacktPublishing/Linux-Device-Drivers-Development
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasklet.c
35 lines (29 loc) · 845 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
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h> /* for tasklets api */
char tasklet_data[]="We use a string; but it could be pointer to a structure";
/* Tasklet handler, that just print the data */
void tasklet_function( unsigned long data )
{
pr_info( "%s\n", (char *)data );
return;
}
DECLARE_TASKLET( my_tasklet, tasklet_function, (unsigned long) tasklet_data );
static int __init my_init( void )
{
/* Schedule the handler */
tasklet_schedule( &my_tasklet );
pr_info("tasklet example\n");
return 0;
}
void my_exit( void )
{
/* Stop the tasklet before we exit */
tasklet_kill( &my_tasklet );
pr_info("tasklet example cleanup\n");
return;
}
module_init(my_init);
module_exit(my_exit);
MODULE_AUTHOR("John Madieu <john.madieu@gmail.com>");
MODULE_LICENSE("GPL");