summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-05-03 13:35:55 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-05 17:37:26 +0000
commitba0dfab0c9c17d94b9a34c70df07d53511ef1948 (patch)
tree482084d6d4f5f693191d0727d214912592950a56
parent12b5ad2a32b631e9b65307861e495dc515d110f6 (diff)
downloadchrome-ec-ba0dfab0c9c17d94b9a34c70df07d53511ef1948.tar.gz
charger: Move processing of battery-present state to func
Split this code out into its own function, called if a change is detected. This changes the ordering of the assignment of need_static but should should not matter. This makes no functional change. BUG=b:218332694 TEST=zmake build dev-posix Change-Id: Ia992c9c03ae2d156b490d071b1b1111d3b077939 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4500687 Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Commit-Queue: Simon Glass <sjg@chromium.org>
-rw-r--r--common/charge_state_v2.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 91f548166d..eac1023e0b 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1761,6 +1761,22 @@ static void process_ac_change(const int chgnum)
}
}
+/* Handle a change in the battery-present state */
+static void process_battery_present_change(const struct charger_info *info,
+ int chgnum)
+{
+ prev_bp = curr.batt.is_present;
+
+ /* Update battery info due to change of battery */
+ batt_info = battery_get_info();
+
+ curr.desired_input_current = get_desired_input_current(prev_bp, info);
+ if (curr.desired_input_current != CHARGE_CURRENT_UNINITIALIZED)
+ charger_set_input_current_limit(chgnum,
+ curr.desired_input_current);
+ hook_notify(HOOK_BATTERY_SOC_CHANGE);
+}
+
/* Main loop */
void charger_task(void *u)
{
@@ -1798,19 +1814,8 @@ void charger_task(void *u)
#endif /* CONFIG_OCPC */
if (prev_bp != curr.batt.is_present) {
- prev_bp = curr.batt.is_present;
-
- /* Update battery info due to change of battery */
- batt_info = battery_get_info();
+ process_battery_present_change(info, chgnum);
need_static = 1;
-
- curr.desired_input_current =
- get_desired_input_current(prev_bp, info);
- if (curr.desired_input_current !=
- CHARGE_CURRENT_UNINITIALIZED)
- charger_set_input_current_limit(
- chgnum, curr.desired_input_current);
- hook_notify(HOOK_BATTERY_SOC_CHANGE);
}
battery_validate_params(&curr.batt);