mirror of
https://github.com/sysprog21/lkmpg.git
synced 2024-11-28 19:33:38 +08:00
faf3aa7c22
It is vital to denote the file name and summary for each source, otherwise readers could not figure out the corresponding files.
38 lines
763 B
C
38 lines
763 B
C
/*
|
|
* example_tasklet.c
|
|
*/
|
|
#include <linux/delay.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
|
|
static void tasklet_fn(unsigned long data)
|
|
{
|
|
pr_info("Example tasklet starts\n");
|
|
mdelay(5000);
|
|
pr_info("Example tasklet ends\n");
|
|
}
|
|
|
|
DECLARE_TASKLET(mytask, tasklet_fn, 0L);
|
|
|
|
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");
|