diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2019-02-27 13:09:54 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-20 19:51:21 -0700 |
commit | 8fb1c6c52510438f77378f08d2b6d881da48dd3f (patch) | |
tree | 177592678efb8a24046fdbb4dffd62f3e2f00a7e /board | |
parent | 06933b4cb6dbb2a36b2d4d6139325575a558836d (diff) | |
download | chrome-ec-8fb1c6c52510438f77378f08d2b6d881da48dd3f.tar.gz |
ec: Refactor get_rtc_diff to return unsigned values
get_rtc_diff in stm32 previously returned a signed value, but the result
could never be negative. This changes the function to return an unsigned
value in a safe manner, and updates its corresponding usage.
The original patch set for this CL included a test for the get_rtc_diff
functionality. This was removed since there was no easy way to make a
host-side test of board-specific functionality. If this is going to
be solved, I will write a separate CL.
BUG=chromium:769407
BRANCH=none
TEST=make buildall -j
TEST=made unit test for get_rtc_diff; test passed (see note above)
Change-Id: Iec1b274294d8f78eaa0ee66d3bd63ce69536e747
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1493035
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/zinger/runtime.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c index 44a93b346a..f92b919398 100644 --- a/board/zinger/runtime.c +++ b/board/zinger/runtime.c @@ -145,7 +145,6 @@ uint32_t task_wait_event(int timeout_us) uint32_t evt; timestamp_t t0, t1; struct rtc_time_reg rtc0, rtc1; - int rtc_diff; t1.val = get_time().val + timeout_us; @@ -190,8 +189,7 @@ uint32_t task_wait_event(int timeout_us) /* fast forward timer according to RTC counter */ reset_rtc_alarm(&rtc1); - rtc_diff = get_rtc_diff(&rtc0, &rtc1); - t0.val = t0.val + rtc_diff; + t0.val += get_rtc_diff(&rtc0, &rtc1); force_time(t0); } |