summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-08-20 20:06:38 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-08-22 07:43:12 +0000
commit44fd786ec9b521a5c61d9dd31a460feae65782cc (patch)
tree88d5fca9e6306284a7dd9c75451ccc205c690a12
parent911d66ead7ca00e54df36b09a25d2b8bad9b5ee3 (diff)
downloadchrome-ec-44fd786ec9b521a5c61d9dd31a460feae65782cc.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> (cherry picked from commit 08f3d2d701b8c78ecbb51c8e48aabf5ad56d4be9) Reviewed-on: https://chromium-review.googlesource.com/1184683 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@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)