diff options
author | Wai-Hong Tam <waihong@google.com> | 2020-09-28 17:41:06 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-13 17:32:47 +0000 |
commit | 846d01788513e375b64fb73205cd58d51525451e (patch) | |
tree | be772194724fa9fe16586e8a8983c0e9424174cb | |
parent | 4e94a3264d66a67f69740441f71f86f06ecff614 (diff) | |
download | chrome-ec-846d01788513e375b64fb73205cd58d51525451e.tar.gz |
charge_state_v2: Move the first battery_get_params to HOOK_INIT
Other tasks read the params like state_of_charge at the beginning of
their tasks. In the existing code, the first battery_get_params is
called at the beginning of the charger task. It is not guaranteed the
battery params are ready. This change moves it to the HOOK_INIT.
BRANCH=None
BUG=b:169453974
TEST=Cut off the battery, checked the first boot has PD-enabled, which
uses the battery state_of_charge param to make the decision.
Change-Id: Ie7bd31ee71fb3d1ea47a31910f0dfa7ac93cbcef
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2436760
Tested-by: Nitin Kolluru <nkolluru@google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869322
Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | common/charge_state_v2.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 64fc7332ac..31cef7b255 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1518,6 +1518,11 @@ void charger_init(void) /* Manual voltage/current set to off */ manual_voltage = -1; manual_current = -1; + /* + * Other tasks read the params like state_of_charge at the beginning of + * their tasks. Make them ready first. + */ + battery_get_params(&curr.batt); } DECLARE_HOOK(HOOK_INIT, charger_init, HOOK_PRIO_DEFAULT); @@ -1592,7 +1597,6 @@ void charger_task(void *u) * then use max input current limit so that we can pull as much power * as needed. */ - battery_get_params(&curr.batt); prev_bp = BP_NOT_INIT; curr.desired_input_current = get_desired_input_current( curr.batt.is_present, info); |