summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2018-12-26 15:32:50 -0800
committerCommit Bot <commit-bot@chromium.org>2021-09-11 23:40:21 +0000
commit3149f15b043bb02d1f4591c57b8cf125ed5ec177 (patch)
tree1bbeb246f9d13748a778c8d32e4ee9ddced9a18a /driver
parentffc28b8480b827ee75347c07c66cec87d6895000 (diff)
downloadchrome-ec-3149f15b043bb02d1f4591c57b8cf125ed5ec177.tar.gz
driver: bmi160: Add temporary variable in decode_header
Use a single variable instead of (s+i) to point to the sensor we are working on. BUG=chromium:917868 BRANCH=eve TEST=With ./mems_start_collection.sh, check samples are collected. Change-Id: Ib05059bea776aec978a8feb350f2dacb8aae7311 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1390940 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Enrico Granata <egranata@chromium.org> (cherry picked from commit a48a9cc46d08223d904e7df97da557b8e960c660) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3145685 Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'driver')
-rw-r--r--driver/accelgyro_bmi160.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index f23e3ddbed..2c744c4bcf 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -786,7 +786,7 @@ static uint8_t bmi160_buffer[BMI160_FIFO_BUFFER];
* @bp: current pointer in the buffer, updated when processing the header.
* @ep: pointer to the end of the valid data in the buffer.
*/
-static int bmi160_decode_header(struct motion_sensor_t *s,
+static int bmi160_decode_header(struct motion_sensor_t *accel,
enum fifo_header hdr, uint32_t last_ts,
uint8_t **bp, uint8_t *ep)
{
@@ -806,20 +806,22 @@ static int bmi160_decode_header(struct motion_sensor_t *s,
}
for (i = MOTIONSENSE_TYPE_MAG; i >= MOTIONSENSE_TYPE_ACCEL;
i--) {
+ struct motion_sensor_t *s = accel + i;
+
if (hdr & (1 << (i + BMI160_FH_PARM_OFFSET))) {
struct ec_response_motion_sensor_data vector;
- int *v = (s + i)->raw_xyz;
+ int *v = s->raw_xyz;
vector.flags = 0;
- normalize(s + i, v, *bp);
+ normalize(s, v, *bp);
#ifdef CONFIG_ACCEL_SPOOF_MODE
- if ((s+i)->in_spoof_mode)
- v = (s+i)->spoof_xyz;
+ if (s->in_spoof_mode)
+ v = s->spoof_xyz;
#endif /* defined(CONFIG_ACCEL_SPOOF_MODE) */
vector.data[X] = v[X];
vector.data[Y] = v[Y];
vector.data[Z] = v[Z];
- vector.sensor_num = i + (s - motion_sensors);
- motion_sense_fifo_add_data(&vector, s + i, 3,
+ vector.sensor_num = s - motion_sensors;
+ motion_sense_fifo_add_data(&vector, s, 3,
last_ts);
*bp += (i == MOTIONSENSE_TYPE_MAG ? 8 : 6);
}