The tasklet_init() function initializes a tasklet; its signature is as follows:
#include <linux/interrupt.h>
void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data);
Let's check out its parameters:
- struct tasklet_struct *t: This structure is the metadata representing the tasklet. As you already know, a pointer, by itself, has no memory! Remember to allocate memory to the data structure and then pass the pointer here.
- void (*func)(unsigned long): This is the tasklet function itself – the "bottom half" that runs once the hardirq completes; this bottom half function performs the majority of the interrupt handling process.
- unsigned long data: Any data item you wish to pass along to the tasklet routine (a cookie).
Where should this initialization work be performed? Typically, this is done within the driver's probe (or init) function. So, now that it's been initialized and is ready...