mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 00:51:29 +00:00
motion: Fix comparison between signed and unsigned integer
If wait_us < 0, comparison against motion_min_interval actually fails, and this negative wait_us causes task_wait_event() never returns if we are not using any motion task event except the timer. The motion task will then stop running and sensor data stay unchanged. BRANCH=none BUG=chrome-os-partner:54092 TEST=hardcode wait_us to a negative value before motion_min_interval check, and see motion task is still running by EC console cmd timerinfo Change-Id: Ic1e7ffeeb9d2ec1f5c5beb4387294014298123af Signed-off-by: Koro Chen <koro.chen@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/358332 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
This commit is contained in:
@@ -827,6 +827,9 @@ void motion_sense_task(void)
|
||||
wait_us = motion_interval -
|
||||
(ts_end_task.val - ts_begin_task.val);
|
||||
|
||||
/* and it cannnot be negative */
|
||||
wait_us = MAX(wait_us, 0);
|
||||
|
||||
/*
|
||||
* Guarantee some minimum delay to allow other lower
|
||||
* priority tasks to run.
|
||||
|
||||
Reference in New Issue
Block a user