Commit e8e9d21a authored by Adrian Hunter's avatar Adrian Hunter Committed by Thomas Gleixner

timekeeping: Refactor timekeeping helpers

Simplify the usage of timekeeping sanity checking, in preparation for
consolidating timekeeping helpers. This works towards eliminating
timekeeping_delta_to_ns() in favour of timekeeping_cycles_to_ns().

No functional change.
Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240325064023.2997-14-adrian.hunter@intel.com
parent 670be12b
...@@ -237,7 +237,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset) ...@@ -237,7 +237,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset)
} }
} }
static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr)
{ {
struct timekeeper *tk = &tk_core.timekeeper; struct timekeeper *tk = &tk_core.timekeeper;
u64 now, last, mask, max, delta; u64 now, last, mask, max, delta;
...@@ -281,17 +281,9 @@ static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) ...@@ -281,17 +281,9 @@ static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr)
static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset)
{ {
} }
static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr)
{ {
u64 cycle_now, delta; BUG();
/* read clocksource */
cycle_now = tk_clock_read(tkr);
/* calculate the delta since the last update_wall_time */
delta = clocksource_delta(cycle_now, tkr->cycle_last, tkr->mask);
return delta;
} }
#endif #endif
...@@ -396,10 +388,10 @@ static __always_inline u64 __timekeeping_get_ns(const struct tk_read_base *tkr) ...@@ -396,10 +388,10 @@ static __always_inline u64 __timekeeping_get_ns(const struct tk_read_base *tkr)
static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr) static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr)
{ {
u64 delta; if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING))
return timekeeping_delta_to_ns(tkr, timekeeping_debug_get_delta(tkr));
delta = timekeeping_get_delta(tkr); return __timekeeping_get_ns(tkr);
return timekeeping_delta_to_ns(tkr, delta);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment