Re: Periodic event in Kernel Module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/8/07, Rick Blundell <rickb@xxxxxxxxxxxx> wrote:

>> This is exactly what I need. add_timer() calling function X in the
> init
>> and then add_timer() in function X.
>>
>
>
> No, I believe you want to do add_timer() calling function X in the init
> and then mod_timer() in function X (or del_timer() if your finished).

I based my statement on the code for kbleds.c at:
http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html

ie:

static int __init kbleds_init(void)
{
..
        init_timer(&my_timer);
        my_timer.function = my_timer_func;
        my_timer.data = (unsigned long)&kbledstatus;
        my_timer.expires = jiffies + BLINK_DELAY;
        add_timer(&my_timer);
        return 0;
}

static void my_timer_func(unsigned long ptr)
{
..
        my_timer.expires = jiffies + BLINK_DELAY;
        add_timer(&my_timer);
}

Note, mod_timer() and add_timer() call into the same function,
__mod_timer(). So just use mod_timer().

Thanks,
Nish

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux