Skip to content

Commit cdea7cd

Browse files
t-8chKAGA-KOKO
authored andcommitted
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
1 parent 44d7fb8 commit cdea7cd

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

include/linux/hrtimer.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
154154
return ktime_to_ns(timer->node.expires);
155155
}
156156

157-
static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
157+
static inline ktime_t hrtimer_cb_get_time(const struct hrtimer *timer)
158158
{
159-
return ktime_sub(timer->node.expires, timer->base->get_time());
159+
return timer->base->get_time();
160160
}
161161

162-
static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)
162+
static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
163163
{
164-
return timer->base->get_time();
164+
return ktime_sub(timer->node.expires, hrtimer_cb_get_time(timer));
165165
}
166166

167167
static inline int hrtimer_is_hres_active(struct hrtimer *timer)
@@ -200,8 +200,7 @@ __hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now)
200200
static inline ktime_t
201201
hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
202202
{
203-
return __hrtimer_expires_remaining_adjusted(timer,
204-
timer->base->get_time());
203+
return __hrtimer_expires_remaining_adjusted(timer, hrtimer_cb_get_time(timer));
205204
}
206205

207206
#ifdef CONFIG_TIMERFD
@@ -363,7 +362,7 @@ hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
363362
static inline u64 hrtimer_forward_now(struct hrtimer *timer,
364363
ktime_t interval)
365364
{
366-
return hrtimer_forward(timer, timer->base->get_time(), interval);
365+
return hrtimer_forward(timer, hrtimer_cb_get_time(timer), interval);
367366
}
368367

369368
/* Precise sleep: */

0 commit comments

Comments
 (0)