From bcb73a6355d21c87ef63ea0a14f0490229da8a24 Mon Sep 17 00:00:00 2001 From: Tommy Chung Date: Wed, 4 Aug 2021 18:55:02 +0800 Subject: chgstv2: call sustain_battery_soc without checking previous states When we enalbe battery sustain after battery returns that it is full, we need to add this condition for sustain_battery_soc(). Also, add this test condition for battery sustainer. BUG=b:188457962 BRANCH=none TEST=make sure the battery sustain works when enabling it after battery returns that it is full. Also, make sure that "make run-sbs_charging_v2" pass. Signed-off-by: Tommy Chung Change-Id: If10b9fd0264717abfb7cdbb7ddc947b370291895 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3070946 Reviewed-by: Devin Lu Reviewed-by: Jack Rosenthal Tested-by: Daisuke Nojiri Commit-Queue: Daisuke Nojiri Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3869645 Auto-Submit: Daisuke Nojiri --- common/charge_state_v2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 9c8c81229a..5b111e6baa 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1935,6 +1935,10 @@ wait_for_it: /* And the EC console */ is_full = calc_is_full(); + + /* Run battery sustainer (no-op if not applicable). */ + sustain_battery_soc(); + if ((!(curr.batt.flags & BATT_FLAG_BAD_STATE_OF_CHARGE) && curr.batt.state_of_charge != prev_charge) || #ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER @@ -1943,7 +1947,6 @@ wait_for_it: (is_full != prev_full) || (curr.state != prev_state) || (charge_get_display_charge() != prev_disp_charge)) { - sustain_battery_soc(); show_charging_progress(); prev_charge = curr.batt.state_of_charge; prev_disp_charge = charge_get_display_charge(); -- cgit v1.2.1