diff options
-rw-r--r-- | common/charge_state_v2.c | 10 | ||||
-rw-r--r-- | common/charger_base.c | 12 | ||||
-rw-r--r-- | include/charger_base.h | 10 |
3 files changed, 23 insertions, 9 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index bd52a682f5..aa7c54ddf1 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1147,17 +1147,15 @@ void check_battery_change_soc(bool is_full, bool prev_full) { if ((!(curr.batt.flags & BATT_FLAG_BAD_STATE_OF_CHARGE) && curr.batt.state_of_charge != prev_charge) || -#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT - (charge_base != prev_charge_base) || -#endif + (IS_ENABLED(CONFIG_EC_EC_COMM_BATTERY_CLIENT) && + charger_base_charge_changed()) || is_full != prev_full || (curr.state != prev_state) || (charge_get_display_charge() != prev_disp_charge)) { show_charging_progress(is_full); prev_charge = curr.batt.state_of_charge; prev_disp_charge = charge_get_display_charge(); -#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT - prev_charge_base = charge_base; -#endif + if (IS_ENABLED(CONFIG_EC_EC_COMM_BATTERY_CLIENT)) + charger_base_charge_update(); hook_notify(HOOK_BATTERY_SOC_CHANGE); } } diff --git a/common/charger_base.c b/common/charger_base.c index 127229068c..9eaf11cc1e 100644 --- a/common/charger_base.c +++ b/common/charger_base.c @@ -23,7 +23,7 @@ /* Base has responded to one of our commands already. */ static int base_responsive; int charge_base; -int prev_charge_base; +static int prev_charge_base; static int prev_current_base; static int prev_allow_charge_base; static int prev_current_lid; @@ -647,5 +647,15 @@ void charger_base_setup(void) base_responsive = 0; } +bool charger_base_charge_changed(void) +{ + return charge_base != prev_charge_base; +} + +void charger_base_charge_update(void) +{ + prev_charge_base = charge_base; +} + /* Reset the base on S5->S0 transition. */ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_base_reset, HOOK_PRIO_DEFAULT); diff --git a/include/charger_base.h b/include/charger_base.h index 511ec2b4ab..8b7ae1421f 100644 --- a/include/charger_base.h +++ b/include/charger_base.h @@ -13,7 +13,6 @@ struct charge_state_data; extern int charge_base; -extern int prev_charge_base; /* allocate power between the base and the lid */ void base_charge_allocate_input_current_limit( @@ -34,8 +33,9 @@ void base_update_battery_info(void); #ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT /* Check if there is a base and it is connected */ bool base_connected(void); + #else -bool base_connected(void) +static inline bool base_connected(void) { return false; } @@ -44,4 +44,10 @@ bool base_connected(void) /* Set up the charger task for the base */ void charger_base_setup(void); +/* Check if charge_base has changed since last time */ +bool charger_base_charge_changed(void); + +/* Update prev_charge_base with charge_base */ +void charger_base_charge_update(void); + #endif /* __CROS_EC_CHARGER_BASE_H */ |