summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-05-28 11:35:56 -0700
committerCommit Bot <commit-bot@chromium.org>2021-07-15 16:18:30 +0000
commit5250d3b79f86709d1029f020965456f457455f01 (patch)
tree4564bea23178a792a7cc3e616635b0ecc532c649
parent8b3035567f4ad4cc4cf8092d69b9dceabd801f7f (diff)
downloadchrome-ec-5250d3b79f86709d1029f020965456f457455f01.tar.gz
chgstv2: Join two battery revival code blocks
The 'else' at line 2085 can accommodate only one statement since it doesn't have a curly brace. So, it's (unintentionally) closed by 'battery_seems_to_be_disconnected = ...', which was inserted by crrev.com/c/210343. It should be closed by the subsequent code ( the code wrapped by CONFIG_BATTERY_REVIVE_DISCONNECT). There are two code blocks which fix unresponsive batteries (i.e. CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD & CONFIG_BATTERY_REVIVE_DISCONNECT). chgstv2 needs to run one of these at a time not both. That is, if CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD is applied, CONFIG_BATTERY_REVIVE_DISCONNECT should be skipped. BUG=None BRANCH=None TEST=buildall Change-Id: Iae13cf6c33d02fe62e89b6c1bb2b5b3dc49ff8fd Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929342 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/battery.c5
-rw-r--r--common/charge_state_v2.c18
2 files changed, 14 insertions, 9 deletions
diff --git a/common/battery.c b/common/battery.c
index 4670b436b0..c24bf59da9 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -702,6 +702,11 @@ int battery_manufacturer_name(char *dest, int size)
return get_battery_manufacturer_name(dest, size);
}
+__overridable enum battery_disconnect_state battery_get_disconnect_state(void)
+{
+ return BATTERY_NOT_DISCONNECTED;
+}
+
#ifdef CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
#if CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV < 5000 || \
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 948789fba6..6f1cc833c5 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -2069,6 +2069,15 @@ void charger_task(void *u)
}
/* The battery is responding. Yay. Try to use it. */
+
+ /*
+ * Always check the disconnect state. This is because
+ * the battery disconnect state is one of the items used
+ * to decide whether or not to leave safe mode.
+ */
+ battery_seems_disconnected =
+ battery_get_disconnect_state() == BATTERY_DISCONNECTED;
+
#ifdef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
/*
* TODO (crosbug.com/p/29467): remove this workaround
@@ -2085,15 +2094,6 @@ void charger_task(void *u)
} else
#endif
#ifdef CONFIG_BATTERY_REVIVE_DISCONNECT
- /*
- * Always check the disconnect state. This is because
- * the battery disconnect state is one of the items used
- * to decide whether or not to leave safe mode.
- */
- battery_seems_to_be_disconnected =
- battery_get_disconnect_state() ==
- BATTERY_DISCONNECTED;
-
if (curr.requested_voltage == 0 &&
curr.requested_current == 0 &&
battery_seems_disconnected) {