diff options
author | Simon Glass <sjg@chromium.org> | 2023-05-05 13:00:40 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-09 22:29:42 +0000 |
commit | 0b3023d675dd0d189a344d8a114aac19a708d296 (patch) | |
tree | e515ccbd94fbfb724c791ef73790afd4bd9b604f /common | |
parent | 0b76ed29fdbb81b0933993c455958883cea4056f (diff) | |
download | chrome-ec-0b3023d675dd0d189a344d8a114aac19a708d296.tar.gz |
charger: Make charge_base static
Move use of this variable wholly within charger_base.c by adding a
function to show the current charge level and another to check if the
base is nearly full.
This makes no functional change.
BUG=b:218332694
TEST=zmake build dev-posix
Check size on lux:
*** 69552 bytes in flash and 1152 bytes in RAM lux RO ****
*** 69460 bytes in flash and 1120 bytes in RAM lux RW ****
Change-Id: I558c3c122f52a8d4e034bd375b20e7ca154fd3a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4510247
Commit-Queue: Simon Glass <sjg@chromium.org>
Reviewed-by: Tomasz Michalec <tmichalec@google.com>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/charge_state_v2.c | 11 | ||||
-rw-r--r-- | common/charger_base.c | 16 |
2 files changed, 19 insertions, 8 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index aa7c54ddf1..473f684262 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -381,9 +381,8 @@ static void show_charging_progress(bool is_full) to_full ? "to full" : "to empty", is_full ? ", not accepting current" : ""); -#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT - CPRINTS("Base battery %d%%", charge_base); -#endif + if (IS_ENABLED(CONFIG_EC_EC_COMM_BATTERY_CLIENT)) + charger_base_show_charge(); if (debugging()) { ccprintf("battery:\n"); @@ -1111,7 +1110,6 @@ static void charger_setup(const struct charger_info *info) #ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT curr.input_voltage = CHARGE_VOLTAGE_UNINITIALIZED; battery_dynamic[BATT_IDX_BASE].flags = EC_BATT_FLAG_INVALID_DATA; - charge_base = -1; #endif #ifdef CONFIG_OCPC ocpc_init(&curr.ocpc); @@ -1727,10 +1725,9 @@ static int battery_near_full(void) if (charge_get_percent() < BATTERY_LEVEL_NEAR_FULL) return 0; -#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT - if (charge_base > -1 && charge_base < BATTERY_LEVEL_NEAR_FULL) + if (IS_ENABLED(CONFIG_EC_EC_COMM_BATTERY_CLIENT) && + !charger_base_charge_near_full()) return 0; -#endif return 1; } diff --git a/common/charger_base.c b/common/charger_base.c index 9eaf11cc1e..03b7f2b461 100644 --- a/common/charger_base.c +++ b/common/charger_base.c @@ -22,7 +22,7 @@ /* Base has responded to one of our commands already. */ static int base_responsive; -int charge_base; +static int charge_base; static int prev_charge_base; static int prev_current_base; static int prev_allow_charge_base; @@ -645,6 +645,7 @@ DECLARE_CONSOLE_COMMAND(chgdualdebug, command_chgdualdebug, void charger_base_setup(void) { base_responsive = 0; + charge_base = -1; } bool charger_base_charge_changed(void) @@ -657,5 +658,18 @@ void charger_base_charge_update(void) prev_charge_base = charge_base; } +void charger_base_show_charge(void) +{ + CPRINTS("Base battery %d%%", charge_base); +} + +bool charger_base_charge_near_full(void) +{ + if (charge_base > -1 && charge_base < BATTERY_LEVEL_NEAR_FULL) + return false; + + return true; +} + /* Reset the base on S5->S0 transition. */ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_base_reset, HOOK_PRIO_DEFAULT); |