Skip to content

Commit e98ab3d

Browse files
ahunter6KAGA-KOKO
authored andcommitted
timekeeping: Move timekeeping helper functions
Move timekeeping helper functions to prepare for their reuse. Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7e90ffb commit e98ab3d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

kernel/time/timekeeping.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -381,23 +381,31 @@ static inline u64 timekeeping_delta_to_ns(const struct tk_read_base *tkr, u64 de
381381
return nsec;
382382
}
383383

384-
static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr)
384+
static inline u64 timekeeping_cycles_to_ns(const struct tk_read_base *tkr, u64 cycles)
385385
{
386386
u64 delta;
387387

388-
delta = timekeeping_get_delta(tkr);
388+
/* calculate the delta since the last update_wall_time */
389+
delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask);
389390
return timekeeping_delta_to_ns(tkr, delta);
390391
}
391392

392-
static inline u64 timekeeping_cycles_to_ns(const struct tk_read_base *tkr, u64 cycles)
393+
static __always_inline u64 fast_tk_get_delta_ns(struct tk_read_base *tkr)
393394
{
394-
u64 delta;
395+
u64 delta, cycles = tk_clock_read(tkr);
395396

396-
/* calculate the delta since the last update_wall_time */
397397
delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask);
398398
return timekeeping_delta_to_ns(tkr, delta);
399399
}
400400

401+
static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr)
402+
{
403+
u64 delta;
404+
405+
delta = timekeeping_get_delta(tkr);
406+
return timekeeping_delta_to_ns(tkr, delta);
407+
}
408+
401409
/**
402410
* update_fast_timekeeper - Update the fast and NMI safe monotonic timekeeper.
403411
* @tkr: Timekeeping readout base from which we take the update
@@ -431,14 +439,6 @@ static void update_fast_timekeeper(const struct tk_read_base *tkr,
431439
memcpy(base + 1, base, sizeof(*base));
432440
}
433441

434-
static __always_inline u64 fast_tk_get_delta_ns(struct tk_read_base *tkr)
435-
{
436-
u64 delta, cycles = tk_clock_read(tkr);
437-
438-
delta = clocksource_delta(cycles, tkr->cycle_last, tkr->mask);
439-
return timekeeping_delta_to_ns(tkr, delta);
440-
}
441-
442442
static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf)
443443
{
444444
struct tk_read_base *tkr;

0 commit comments

Comments
 (0)