From f11b31e9125a24b47d551f81f8d5ec92f5f17173 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Wed, 26 Apr 2023 12:42:38 -0500 Subject: hwtimer: define MAX_TIME_USEC 0xffffffff is the maximum source time. Define a constant and use it everywhere the source time is referenced. BUG=b:262036852 TEST=none Change-Id: I788515261ec8a1e810cc1fa1983ee348dbe091c4 Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4481392 Reviewed-by: Vadim Bendebury --- chip/g/hwtimer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chip/g/hwtimer.c b/chip/g/hwtimer.c index 0e0251ca39..fe5db33858 100644 --- a/chip/g/hwtimer.c +++ b/chip/g/hwtimer.c @@ -31,7 +31,8 @@ * equivalent of approximately 0xffffffff usecs. Note that we lose 3us on * timer wrap due to loss of precision during division. */ -#define TIMELS_MAX (usecs_to_ticks(0xffffffff)) +#define MAX_TIME_USEC 0xffffffff +#define TIMELS_MAX (usecs_to_ticks(MAX_TIME_USEC)) /* * The below calculation is lightweight and can be implemented using @@ -114,7 +115,7 @@ uint32_t __hw_clock_source_read(void) void __hw_clock_source_set(uint32_t ts) { - GREG32(TIMELS, SOURCE(LOAD)) = usecs_to_ticks(0xffffffff - ts); + GREG32(TIMELS, SOURCE(LOAD)) = usecs_to_ticks(MAX_TIME_USEC - ts); } /* This handles rollover in the HW timer */ -- cgit v1.2.1