diff options
author | Koro Chen <koro.chen@mediatek.com> | 2016-07-05 15:40:49 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2017-05-01 21:20:15 +0000 |
commit | 024c9c43ab32acd23ff9b65c74eac90382292ad6 (patch) | |
tree | 3eef6656a07d786af7e17b518d772bf030693782 | |
parent | a52a27fc1ddb1f25e919b54f3df1da484d6cfa22 (diff) | |
download | chrome-ec-024c9c43ab32acd23ff9b65c74eac90382292ad6.tar.gz |
UPSTREAM: 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, ultima
BUG=chrome-os-partner:54092, b:36973851
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
Reviewed-on: https://chromium-review.googlesource.com/358332
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364930
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/409500
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit 9f9c1373ac8326df79c95a3347b0cbb4ccd17580)
Change-Id: Ic1e7ffeeb9d2ec1f5c5beb4387294014298123af
Signed-off-by: Koro Chen <koro.chen@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/489773
-rw-r--r-- | common/motion_sense.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 758d995e83..da9e10d7e5 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -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. |