diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2015-09-23 12:30:14 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-10-02 12:55:51 -0700 |
commit | 229094b2455e093c95d07251a0021f3b637e813c (patch) | |
tree | 9f9000c571d4c4dca79737902d14fe4a6a84643f /common/als.c | |
parent | 2aebfda07f3fe4d3ee058022f088283b35f4f976 (diff) | |
download | chrome-ec-229094b2455e093c95d07251a0021f3b637e813c.tar.gz |
ALS: Disable the ALS task if all the ALS inits fail
BUG=none
TEST=Manually tested on Kunimitsu & Strago.
Removed the ALS sensor from DUT, using "taskinfo" console command
observed that the ALS task is not running.
BRANCH=none
Change-Id: I96cb720bd8d70033d433cdc2cd9cea9b56a3b389
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/301753
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'common/als.c')
-rw-r--r-- | common/als.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/common/als.c b/common/als.c index 17bff66961..06bd734ef0 100644 --- a/common/als.c +++ b/common/als.c @@ -48,7 +48,27 @@ void als_task(void) static void als_task_enable(void) { - task_timeout = ALS_POLL_PERIOD; + int fail_count = 0; + int err; + int i; + + for (i = 0; i < EC_ALS_ENTRIES && i < ALS_COUNT; i++) { + err = als[i].init(); + if (err) { + fail_count++; + ccprintf("%s ALS sensor failed to initialize, err=%d\n", + als[i].name, err); + } + } + + /* + * If all the ALS filed to initialize, disable the ALS task. + */ + if (fail_count == ALS_COUNT) + task_timeout = -1; + else + task_timeout = ALS_POLL_PERIOD; + task_wake(TASK_ID_ALS); } @@ -57,7 +77,7 @@ static void als_task_disable(void) task_timeout = -1; } -DECLARE_HOOK(HOOK_CHIPSET_RESUME, als_task_enable, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_RESUME, als_task_enable, HOOK_PRIO_ALS_INIT); DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, als_task_disable, HOOK_PRIO_DEFAULT); /*****************************************************************************/ |