diff options
author | Aseda Aboagye <aaboagye@google.com> | 2015-08-06 11:21:34 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-08-25 20:57:00 +0000 |
commit | a72329a8e2c528d1c6c07a44e5b6d6bd2aa6e405 (patch) | |
tree | 8c837cfd1b5510f65fb0bede11d5bb530bb931e7 | |
parent | 13cac7664c38470450b97ac78c879332bf49fd95 (diff) | |
download | chrome-ec-a72329a8e2c528d1c6c07a44e5b6d6bd2aa6e405.tar.gz |
UPSTREAM: motion_sense: Reduce condition for lid angle calc.
The motion sense task was checking to see that every single motion
sensor was ready (active, initialized, and reading), before performing
the lid angle calculations. This amount of checking is unnecessary.
This commit reduces the condition to only check if the sensors required
for lid angle calculation are ready.
BUG=chrome-os-partner:36132, b:27849483
BRANCH=samus
TEST=Build and flash on samus. Verify that the lid still works.
TEST=make -j buildall tests
Change-Id: Ibaa5cc8358cdcc6023a50aed247fce2e599fef58
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/291301
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 3a659c1fedb3536a6f04b80b65ff18df6ddb653f)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/370513
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | common/motion_sense.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 465674fb56..cad99aa633 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -411,8 +411,12 @@ void motion_sense_task(void) int i, ret, wait_us, fifo_flush_needed = 0; timestamp_t ts_begin_task, ts_end_task; uint32_t event = 0; - int rd_cnt; + uint16_t ready_status; struct motion_sensor_t *sensor; +#ifdef CONFIG_LID_ANGLE + const uint16_t lid_angle_sensors = ((1 << CONFIG_LID_ANGLE_SENSOR_BASE)| + (1 << CONFIG_LID_ANGLE_SENSOR_LID)); +#endif #ifdef CONFIG_ACCEL_FIFO timestamp_t ts_last_int; #endif @@ -431,7 +435,7 @@ void motion_sense_task(void) #endif do { ts_begin_task = get_time(); - rd_cnt = 0; + ready_status = 0; for (i = 0; i < motion_sensor_count; ++i) { sensor = &motion_sensors[i]; @@ -450,7 +454,7 @@ void motion_sense_task(void) &fifo_flush_needed); if (ret != EC_SUCCESS) continue; - rd_cnt++; + ready_status |= (1 << i); mutex_lock(&g_sensor_mutex); memcpy(sensor->xyz, sensor->raw_xyz, sizeof(sensor->xyz)); @@ -464,12 +468,11 @@ void motion_sense_task(void) #endif #ifdef CONFIG_LID_ANGLE /* - * TODO (crosbug.com/p/36132): Checking for ALL sensors on is - * overkill. It should just check for ACCEL in BASE and ACCEL - * in LID, since those are the only ones needed for the lid - * calculation. + * Check to see that the sensors required for lid angle + * calculation are ready. */ - if (rd_cnt == motion_sensor_count) + ready_status &= lid_angle_sensors; + if (ready_status == lid_angle_sensors) motion_lid_calc(); #endif #ifdef CONFIG_CMD_ACCEL_INFO |