driver: bmi160: Fix logic issue when accelerometer is not first sensor

BMI160 driver assumes accel, gyro, compass are next to each other.
It was also assuming accel was sensor 0, which is wrong.

BUG=none
BRANCH=glados
TEST=On Cave, check sensors 1 (accel) and 2 (gyro) are working properly.

Change-Id: I37402e1d48070caaecbd7e32bbf53754616ee8cb
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Gwendal Grignou
2016-10-05 14:12:07 -07:00
committed by chrome-bot
parent 0ea4603143
commit f11271c8ee

View File

@@ -919,9 +919,7 @@ static int bmi160_decode_header(struct motion_sensor_t *s,
size += (i == MOTIONSENSE_TYPE_MAG ? 8 : 6);
}
if (*bp + size > BUFFER_END(bmi160_buffer)) {
/* frame is not complete, it
* will be retransmitted.
*/
/* frame is not complete, it will be retransmitted. */
*bp = BUFFER_END(bmi160_buffer);
return 1;
}
@@ -935,7 +933,7 @@ static int bmi160_decode_header(struct motion_sensor_t *s,
vector.data[X] = v[X];
vector.data[Y] = v[Y];
vector.data[Z] = v[Z];
vector.sensor_num = i;
vector.sensor_num = i + (s - motion_sensors);
motion_sense_fifo_add_unit(&vector, s + i, 3);
*bp += (i == MOTIONSENSE_TYPE_MAG ? 8 : 6);
}