From d76c5fc90e4b820bc1cbbc86c87377fac32c3c56 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 6 Feb 2020 15:32:19 -0700 Subject: battery: set correct battery cutoff state The battery cutoff state was not updated when using the "at-shutdown" option. This caused the EC to continue charging the battery following cutoff. BUG=none BRANCH=none TEST=make buildall -j TEST=Run "ectool batterycutoff at-shutdown" and then "shutdown -h now". Verify the EC stops charging the battery and the battery voltage is reported as 0. Change-Id: I7aef46a4a4840ea1b17234f4d90ebf7e074a873b Signed-off-by: Keith Short Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2042902 Reviewed-by: Daisuke Nojiri (cherry picked from commit 495146176d87c0f05a326571731e32dfd2602a4d) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2501803 Tested-by: David Huang Auto-Submit: David Huang Reviewed-by: Ting Shen Commit-Queue: Ting Shen --- common/battery.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/battery.c b/common/battery.c index 850d703954..3fecc44c00 100644 --- a/common/battery.c +++ b/common/battery.c @@ -305,10 +305,13 @@ static void pending_cutoff_deferred(void) rv = board_cut_off_battery(); - if (rv == EC_RES_SUCCESS) + if (rv == EC_RES_SUCCESS) { CUTOFFPRINTS("succeeded."); - else + battery_cutoff_state = BATTERY_CUTOFF_STATE_CUT_OFF; + } else { CUTOFFPRINTS("failed!"); + battery_cutoff_state = BATTERY_CUTOFF_STATE_NORMAL; + } } DECLARE_DEFERRED(pending_cutoff_deferred); -- cgit v1.2.1