summaryrefslogtreecommitdiff
path: root/common/motion_sense_fifo.c
diff options
context:
space:
mode:
authorChing-Kang Yen <chingkang@chromium.org>2020-07-31 01:18:51 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-03 07:15:31 +0000
commitdd4ecd1149d7db84cd7d4ff49481c156126dfc2c (patch)
treec4dc82431b19d08330193c63ef3847dedbe4613d /common/motion_sense_fifo.c
parenta72f9b006f2b66fe40b5e14e1bf258428de01558 (diff)
downloadchrome-ec-dd4ecd1149d7db84cd7d4ff49481c156126dfc2c.tar.gz
common: motion_sense_fifo: modify SENSOR_COUNT
When the CONFIG_GESTURE_HOST_DETECTION is defined, there will be an extra activity sensor. However, the motion_sense_fifo only use SENSOR_NUM for the number of sensors. This might cause overflow issues. Introduce a new variable MAX_MOTION_SENSORS that represents the SENSOR_COUNT (+ 1 when activity sensor is available). Replace all SENSOR_COUNT in motion_sensor_fifo.c to MAX_MOTION_SENSORS. BRANCH=None BUG=b:123434029 TEST=make buildall Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I39fc9d77c0aa9a23f9931d4b27905b678081d3bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2329110 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
Diffstat (limited to 'common/motion_sense_fifo.c')
-rw-r--r--common/motion_sense_fifo.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/common/motion_sense_fifo.c b/common/motion_sense_fifo.c
index ee2ab70a32..2325de4c87 100644
--- a/common/motion_sense_fifo.c
+++ b/common/motion_sense_fifo.c
@@ -31,7 +31,7 @@
struct fifo_staged {
uint32_t read_ts;
uint16_t count;
- uint8_t sample_count[SENSOR_COUNT];
+ uint8_t sample_count[MAX_MOTION_SENSORS];
uint8_t requires_spreading;
};
@@ -57,7 +57,7 @@ static struct fifo_staged fifo_staged;
* Cached expected timestamp per sensor. If a sensor's timestamp pre-dates this
* timestamp it will be fast forwarded.
*/
-static struct timestamp_state next_timestamp[SENSOR_COUNT];
+static struct timestamp_state next_timestamp[MAX_MOTION_SENSORS];
/**
* Bitmap telling which sensors have valid entries in the next_timestamp array.
@@ -169,7 +169,7 @@ static void fifo_pop(void)
int i;
fifo_staged.requires_spreading = 0;
- for (i = 0; i < SENSOR_COUNT; i++) {
+ for (i = 0; i < MAX_MOTION_SENSORS; i++) {
if (fifo_staged.sample_count[i] > 1) {
fifo_staged.requires_spreading = 1;
break;
@@ -214,7 +214,7 @@ static void fifo_ensure_space(void)
*/
static inline bool is_new_timestamp(uint8_t sensor_num)
{
- return sensor_num < SENSOR_COUNT &&
+ return sensor_num < MAX_MOTION_SENSORS &&
!(next_timestamp_initialized & BIT(sensor_num));
}
@@ -413,7 +413,7 @@ void motion_sense_fifo_stage_data(
void motion_sense_fifo_commit_data(void)
{
/* Cached data periods, static to store off stack. */
- static uint32_t data_periods[SENSOR_COUNT];
+ static uint32_t data_periods[MAX_MOTION_SENSORS];
struct ec_response_motion_sensor_data *data;
int i, window, sensor_num;
@@ -447,7 +447,7 @@ void motion_sense_fifo_commit_data(void)
window = time_until(data->timestamp, fifo_staged.read_ts);
/* Update the data_periods as needed for this flush. */
- for (i = 0; i < SENSOR_COUNT; i++) {
+ for (i = 0; i < MAX_MOTION_SENSORS; i++) {
int period;
/* Skip empty sensors. */