Hao Shen
Hao Shen

Reputation: 2755

Using the hrtimer callback function, is it possible to give function parameters?

So if I use like:

.............................

enum hrtimer_restart my_hrtimer_callback( struct hrtimer *timer )

.............................

hr_timer.function = &my_hrtimer_callback;
...............................
hrtimer_start(hr_timer,ktime,HRTIMER_MODE_REL);
...............................

Is it possible to pass any parameters to the callback function during the start of the timer? I google a little bit but didn't find a clue. How to use that?

Thanks;>

Upvotes: 3

Views: 2363

Answers (1)

bdonlan
bdonlan

Reputation: 231443

Embed the struct hrtimer in a structure of your creation that has any additional information you may need. Then use container_of() to get the pointer to the containing structure from the timer argument.

Upvotes: 6

Related Questions