From ac1c82a35bd0fd41233ec0b0ba13b32f2ea4a331 Mon Sep 17 00:00:00 2001 From: Sheng-Liang Song Date: Wed, 1 Oct 2014 18:07:06 -0700 Subject: [PATCH] samus: Fixed a bug in host_sensor_id_to_motion_sensor BUG=chrome-os-partner:32368 BRANCH=ToT TEST=Verified on Samus. cd /sys/bus/iio/devices/iio:device0 cat *peak_scale Change-Id: I2b0606e55bfa5e498255c6c42240ee3f9236e4f1 Signed-off-by: Sheng-Liang Song Reviewed-on: https://chromium-review.googlesource.com/220991 Reviewed-by: Alec Berg --- common/motion_sense.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/motion_sense.c b/common/motion_sense.c index f157838f12..12d893f826 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -432,29 +432,28 @@ static struct motion_sensor_t for (i = 0; i < motion_sensor_count; ++i) { + sensor = &motion_sensors[i]; + if ((LOCATION_BASE == sensor->location) && (SENSOR_ACCELEROMETER == sensor->type) && (host_id == EC_MOTION_SENSOR_ACCEL_BASE)) { - sensor = &motion_sensors[i]; break; } if ((LOCATION_LID == sensor->location) && (SENSOR_ACCELEROMETER == sensor->type) && (host_id == EC_MOTION_SENSOR_ACCEL_LID)) { - sensor = &motion_sensors[i]; break; } if ((LOCATION_BASE == sensor->location) && (SENSOR_GYRO == sensor->type) && (host_id == EC_MOTION_SENSOR_GYRO)) { - sensor = &motion_sensors[i]; break; } } - if (!sensor) + if (i == motion_sensor_count) return NULL; if ((sensor->power == SENSOR_POWER_ON)