Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;>

like image 337
Hao Shen Avatar asked Feb 19 '26 21:02

Hao Shen


1 Answers

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.

like image 126
bdonlan Avatar answered Feb 21 '26 11:02

bdonlan