summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-08-20 20:06:38 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-22 00:10:39 -0700
commit08f3d2d701b8c78ecbb51c8e48aabf5ad56d4be9 (patch)
tree893603ae8761a24e497fc899da9ce85400ce5c85
parent1237ea235ff53c1929a485dfc996a13a7d8eacce (diff)
downloadchrome-ec-08f3d2d701b8c78ecbb51c8e48aabf5ad56d4be9.tar.gz
bmi160: End IRQ handler if sensor isn't powered.
It's possible for the interrupt to be triggered and then when the bottom half of the interrupt handler gets a chance to run, the sensor isn't powered anymore. This commit simply has the loop terminate early if the board indicates that the bus the sensor is on is no longer powered. BUG=b:111683988 BRANCH=nocturne TEST=Verify if IRQ handler is called when sensor is not powered, the irq_handler loop terminates. Change-Id: Iaf395902bb4b46a5b6d750c99767c4c36b1e7a99 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1182879 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org>
-rw-r--r--driver/accelgyro_bmi160.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index aa911e3f0c..2d03b06bd1 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -1088,6 +1088,7 @@ 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;
+ int rv;
if ((s->type != MOTIONSENSE_TYPE_ACCEL) ||
(!(*event & CONFIG_ACCELGYRO_BMI160_INT_EVENT)))
@@ -1100,7 +1101,11 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
* 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)