Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hrtimer: Use hrtimer_cb_get_time() helper

Various other helpers contain open-coded implementations of
hrtimer_cb_get_time(). This prevents refactoring the implementation.

Reuse the existing helper.

For this to work, move hrtimer_cb_get_time() a bit up in the file and also
make its argument 'const'.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/20250821-hrtimer-cleanup-get_time-v2-7-3ae822e5bfbd@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
cdea7cda 44d7fb8a

+8 -9
+8 -9
include/linux/hrtimer.h
··· 154 154 return ktime_to_ns(timer->node.expires); 155 155 } 156 156 157 - static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) 158 - { 159 - return ktime_sub(timer->node.expires, timer->base->get_time()); 160 - } 161 - 162 - static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer) 157 + static inline ktime_t hrtimer_cb_get_time(const struct hrtimer *timer) 163 158 { 164 159 return timer->base->get_time(); 160 + } 161 + 162 + static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) 163 + { 164 + return ktime_sub(timer->node.expires, hrtimer_cb_get_time(timer)); 165 165 } 166 166 167 167 static inline int hrtimer_is_hres_active(struct hrtimer *timer) ··· 200 200 static inline ktime_t 201 201 hrtimer_expires_remaining_adjusted(const struct hrtimer *timer) 202 202 { 203 - return __hrtimer_expires_remaining_adjusted(timer, 204 - timer->base->get_time()); 203 + return __hrtimer_expires_remaining_adjusted(timer, hrtimer_cb_get_time(timer)); 205 204 } 206 205 207 206 #ifdef CONFIG_TIMERFD ··· 362 363 static inline u64 hrtimer_forward_now(struct hrtimer *timer, 363 364 ktime_t interval) 364 365 { 365 - return hrtimer_forward(timer, timer->base->get_time(), interval); 366 + return hrtimer_forward(timer, hrtimer_cb_get_time(timer), interval); 366 367 } 367 368 368 369 /* Precise sleep: */