summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/accelgyro_bmi160.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index 0913ba4731..b2c4a630dc 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -1095,20 +1095,19 @@ static void irq_set_orientation(struct motion_sensor_t *s,
*/
static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
{
- uint32_t interrupt, last_ts;
+ uint32_t interrupt;
+ int rv;
if ((s->type != MOTIONSENSE_TYPE_ACCEL) ||
(!(*event & CONFIG_ACCELGYRO_BMI160_INT_EVENT)))
return EC_ERROR_NOT_HANDLED;
do {
- /*
- * Collect timestamp before resetting the interrupt line:
- * After reading, it is possible for the timestamp to change,
- * before we can process the FIFO.
- */
- last_ts = last_interrupt_timestamp;
- raw_read32(s->port, s->addr, BMI160_INT_STATUS_0, &interrupt);
+ rv = raw_read32(s->port, s->addr, BMI160_INT_STATUS_0,
+ &interrupt);
+ /* Bail out of this loop if the sensor isn't powered. */
+ if (rv == EC_ERROR_NOT_POWERED)
+ return rv;
#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
if (interrupt & BMI160_D_TAP_INT)
@@ -1120,7 +1119,7 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
#endif
#ifdef CONFIG_ACCEL_FIFO
if (interrupt & (BMI160_FWM_INT | BMI160_FFULL_INT))
- load_fifo(s, last_ts);
+ load_fifo(s, last_interrupt_timestamp);
#endif
#ifdef CONFIG_BMI160_ORIENTATION_SENSOR
irq_set_orientation(s, interrupt);