summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/als_si114x.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/driver/als_si114x.c b/driver/als_si114x.c
index b9c6e5ecc5..9d9b87006c 100644
--- a/driver/als_si114x.c
+++ b/driver/als_si114x.c
@@ -100,21 +100,25 @@ static int si114x_read_results(struct motion_sensor_t *s, int nb)
&val);
if (ret)
break;
- /* Add offset, calibration */
- if (val + type_data->offset <= 0) {
+ if (val == SI114X_OVERFLOW) {
+ /* overflowing, try next time. */
+ return EC_SUCCESS;
+ } else if (val + type_data->offset <= 0) {
+ /* No light */
val = 1;
- } else if (val != SI114X_OVERFLOW) {
+ } else {
+ /* Add offset, calibration */
val += type_data->offset;
- /*
- * Proxmitiy sensor data is inverse of the distance.
- * Return back something proportional to distance,
- * we affine with the scale parmeter.
- */
- if (s->type == MOTIONSENSE_TYPE_PROX)
- val = SI114X_PS_INVERSION(val);
- val = val * type_data->scale +
- val * type_data->uscale / 10000;
}
+ /*
+ * Proximity sensor data is inverse of the distance.
+ * Return back something proportional to distance,
+ * we correct later with the scale parameter.
+ */
+ if (s->type == MOTIONSENSE_TYPE_PROX)
+ val = SI114X_PS_INVERSION(val);
+ val = val * type_data->scale +
+ val * type_data->uscale / 10000;
s->raw_xyz[i] = val;
}