Every user of init_timer() also needs to initialize ->function and ->data fields. This patch adds a simple setup_timer() helper for that. The schedule_timeout() is patched as an example of usage.
Showing the changes to kernel/timer.c (1 of 3 files). Show all
Unified · Split
| @@ -1146,12 +1146,8 @@ fastcall signed long __sched schedule_timeout(signed long timeout) · 1145 unmodified lines | ||
| 1146 | 1146 | |
| 1147 | 1147 | expire = timeout + jiffies; |
| 1148 | 1148 | |
| 1149 | − init_timer(&timer); | |
| 1150 | − timer.expires = expire; | |
| 1151 | − timer.data = (unsigned long) current; | |
| 1152 | − timer.function = process_timeout; | |
| 1153 | − | |
| 1154 | − add_timer(&timer); | |
| 1149 | + setup_timer(&timer, process_timeout, (unsigned long)current); | |
| 1150 | + __mod_timer(&timer, expire); | |
| 1155 | 1151 | schedule(); |
| 1156 | 1152 | del_singleshot_timer_sync(&timer); |
| 1157 | 1153 | |