From: Thadeu Lima de Souza Cascardo Date: Fri, 21 May 2010 15:16:12 +0000 (-0400) Subject: Use tasklet to schedule printing our default greeting. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fkernel%2Fsamples%2Fchar2%2F.git;a=commitdiff_plain;h=refs%2Fheads%2Ftasklet Use tasklet to schedule printing our default greeting. --- diff --git a/hellochar.c b/hellochar.c index d8adcf9..91e8d69 100644 --- a/hellochar.c +++ b/hellochar.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include MODULE_LICENSE("GPL"); @@ -41,14 +41,13 @@ static void hello_world(unsigned long greeting) printk(KERN_INFO "%s", (char *) greeting); } -static DEFINE_TIMER(hello_timer, hello_world, 0, def_greeting); +static DECLARE_TASKLET(hello_tasklet, hello_world, def_greeting); static ssize_t hello_read(struct file *fp, char __user *buf, size_t sz, loff_t *pos) { - printk(KERN_INFO "Adding timer...\n"); - hello_timer.expires = jiffies + 5 * HZ; - add_timer(&hello_timer); + printk(KERN_INFO "Scheduling tasklet...\n"); + tasklet_schedule(&hello_tasklet); return 0; } @@ -98,7 +97,7 @@ reg_out: static void __exit ch_exit(void) { - del_timer_sync(&hello_timer); + tasklet_kill(&hello_tasklet); cdev_del(dev); unregister_chrdev_region(devnum, 256); }