summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-05-03 11:01:54 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-05 15:15:22 +0000
commitd056bd5a65d3247bc1ff64cd0024eddcefce2db8 (patch)
treef4b23c03993ab8d85679c889e9a9a29886039163
parent70e2504d1886c585bc74c6f624887719e3f0a351 (diff)
downloadchrome-ec-d056bd5a65d3247bc1ff64cd0024eddcefce2db8.tar.gz
charger: Move setup into its own function
The charger_task() function is extremely long. Start to split it up by creating a charger_setup() function for the initial setup code. This makes no functional change. BUG=b:218332694 TEST=zmake build dev-posix Change-Id: I12b3ff29c59418ce0819fa28973a8be7a4574dd9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4501286 Reviewed-by: Aaron Massey <aaronmassey@google.com> Tested-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
-rw-r--r--common/charge_state_v2.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 2835f6b7f8..c0139748a0 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1635,16 +1635,9 @@ static void revive_battery(int *need_static)
battery_seems_dead = battery_was_removed = 0;
}
-/* Main loop */
-void charger_task(void *u)
+/* Set up the initial state of the charger task */
+static void charger_setup(const struct charger_info *info)
{
- int sleep_usec;
- int battery_critical;
- int need_static = 1;
- const struct charger_info *const info = charger_get_info();
- int prev_plt_and_desired_mw;
- int chgnum = 0;
-
/* Get the battery-specific values */
batt_info = battery_get_info();
@@ -1685,6 +1678,20 @@ void charger_task(void *u)
}
battery_level_shutdown = board_set_battery_level_shutdown();
+}
+
+/* Main loop */
+void charger_task(void *u)
+{
+ int sleep_usec;
+ int battery_critical;
+ int need_static = 1;
+ const struct charger_info *const info = charger_get_info();
+ int prev_plt_and_desired_mw;
+ int chgnum = 0;
+
+ /* Set up the task - note that charger_init() has already run. */
+ charger_setup(info);
while (1) {
/* Let's see what's going on... */