summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-11-18 13:39:44 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-08-25 20:59:45 +0000
commitaa4e5d813198b6c0ca2fb2374745a668f673764a (patch)
tree69aae06bb702b789f958fd72ff907d1ce58ee42b
parentec81ff7a6c09eba1b40a53df4b6f10acaf756a8e (diff)
downloadchrome-ec-aa4e5d813198b6c0ca2fb2374745a668f673764a.tar.gz
UPSTREAM: motion: At shutdown, access sensors only if initialized.
When sensor_shutdown() is called, the sensors may already been powered off, or will be soon. In that case, do not attempts to access them. Check their state before setting range or disabling activities. BRANCH=smaug, samus BUG=chromium:557966, b:27849483 TEST=compile Change-Id: I60640b120a23f9aab393a93c4c67ef17222ced4e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/314382 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit cef0fdb90e17fae3fd9f035bb6ada17e2833369e) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/370564
-rw-r--r--common/motion_sense.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 5a6588bedb..80885fabb8 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -426,21 +426,28 @@ static void motion_sense_shutdown(void)
#endif
sensor_active = SENSOR_ACTIVE_S5;
-
for (i = 0; i < motion_sensor_count; i++) {
sensor = &motion_sensors[i];
/* Forget about changes made by the AP */
sensor->config[SENSOR_CONFIG_AP].odr = 0;
sensor->config[SENSOR_CONFIG_AP].ec_rate = 0;
- sensor->drv->set_range(sensor, sensor->default_range, 0);
}
motion_sense_switch_sensor_rate();
+
+ for (i = 0; i < motion_sensor_count; i++) {
+ sensor = &motion_sensors[i];
+ if (sensor->state != SENSOR_INITIALIZED)
+ continue;
+ sensor->drv->set_range(sensor, sensor->default_range, 0);
+ }
/* Forget activities set by the AP */
#ifdef CONFIG_GESTURE_DETECTION_MASK
mask = CONFIG_GESTURE_DETECTION_MASK;
while (mask) {
i = get_next_bit(&mask);
sensor = &motion_sensors[i];
+ if (sensor->state != SENSOR_INITIALIZED)
+ continue;
sensor->drv->list_activities(sensor,
&enabled, &disabled);
/* exclude double tap, it is used internally. */