diff options
-rw-r--r-- | common/motion_sense.c | 5 | ||||
-rw-r--r-- | driver/accelgyro_bmi160.c | 2 | ||||
-rw-r--r-- | driver/als_si114x.c | 9 | ||||
-rw-r--r-- | include/accelgyro.h | 5 | ||||
-rw-r--r-- | include/common.h | 2 |
5 files changed, 16 insertions, 7 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/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index f781313243..cbbb78f7cb 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -713,7 +713,7 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event) if ((s->type != MOTIONSENSE_TYPE_ACCEL) || (!(*event & CONFIG_ACCELGYRO_BMI160_INT_EVENT))) - return EC_SUCCESS; + return EC_ERROR_NOT_HANDLED; raw_read32(s->addr, BMI160_INT_STATUS_0, &interrupt); diff --git a/driver/als_si114x.c b/driver/als_si114x.c index 52d3a3ae7b..944712f655 100644 --- a/driver/als_si114x.c +++ b/driver/als_si114x.c @@ -155,11 +155,14 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event) struct si114x_typed_data_t *type_data = SI114X_GET_TYPED_DATA(s); if (!(*event & CONFIG_ALS_SI114X_INT_EVENT)) - return EC_SUCCESS; + return EC_ERROR_NOT_HANDLED; ret = raw_read8(s->addr, SI114X_REG_IRQ_STATUS, &val); - if (ret < 0 || !(val & type_data->irq_flags)) - return EC_SUCCESS; + if (ret) + return ret; + + if (!(val & type_data->irq_flags)) + return EC_ERROR_INVAL; /* clearing IRQ */ ret = raw_write8(s->addr, SI114X_REG_IRQ_STATUS, 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 |