summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-08 11:34:42 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-08-01 16:38:38 +0000
commit5578ea07d8f088e0e37ff1eb0c07f037875d1ff3 (patch)
treee6ccbb3380e0813fd6199cba8a3df31abba0581d
parent6aa448c6b9bfb3bbf6d0e45ac8af85cc7c34879a (diff)
downloadchrome-ec-5578ea07d8f088e0e37ff1eb0c07f037875d1ff3.tar.gz
BACKPORT: common: accel: Add error code for irq handler
When IRQ handler is not processing any event raised, return NOT_HANDLED. Without this change, any event would set the light sensor process timestamp and, if the light sensor frequency was lower than BM160 fifo interrupt frequency, we would never read from the light sensor. BRANCH=smaug, cyan BUG=chrome-os-partner:43800, b:27849483 TEST=Compile. Check that light sensor data get updated. Change-Id: I302f80c5cd9b4f3c926362fdafdc8b5074cabb60 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/298686 (cherry picked from commit 33046e7d51af5d521235c79dcddc3308c71189db) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359376
-rw-r--r--common/motion_sense.c5
-rw-r--r--include/accelgyro.h5
-rw-r--r--include/common.h2
3 files changed, 9 insertions, 3 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 89d2f4e77b..5a1afb353d 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -497,8 +497,9 @@ static int motion_sense_process(struct motion_sensor_t *sensor,
#ifdef CONFIG_ACCEL_INTERRUPTS
if ((*event & TASK_EVENT_MOTION_INTERRUPT_MASK) &&
(sensor->drv->irq_handler != NULL)) {
- sensor->drv->irq_handler(sensor, event);
- sensor->last_collection = ts->le.lo;
+ ret = sensor->drv->irq_handler(sensor, event);
+ if (ret == EC_SUCCESS)
+ sensor->last_collection = ts->le.lo;
}
#endif
#ifdef CONFIG_ACCEL_FIFO
diff --git a/include/accelgyro.h b/include/accelgyro.h
index f9b68f0e36..a941c2fcb9 100644
--- a/include/accelgyro.h
+++ b/include/accelgyro.h
@@ -104,7 +104,10 @@ struct accelgyro_drv {
* handler for interrupts triggered by the sensor: it runs in task and
* process the events that triggered an interrupt.
* @s Pointer to sensor data.
- * @event Event to process. May add add other events for the next processor.
+ * @event Event to process. May add other events for the next processor.
+ *
+ * Return EC_SUCCESS when one event is handled, EC_ERROR_NOT_HANDLED
+ * when no events have been proccessed.
*/
int (*irq_handler)(struct motion_sensor_t *s, uint32_t *event);
#endif
diff --git a/include/common.h b/include/common.h
index a372b8cf0d..fe51a9b79b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -116,6 +116,8 @@ enum ec_error_list {
EC_ERROR_PARAM9 = 19,
EC_ERROR_PARAM_COUNT = 20, /* Wrong number of params */
+ EC_ERROR_NOT_HANDLED = 21, /* Interrupt event not handled */
+
/* Module-internal error codes may use this range. */
EC_ERROR_INTERNAL_FIRST = 0x10000,
EC_ERROR_INTERNAL_LAST = 0x1FFFF