diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2018-06-30 11:24:13 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-23 21:04:58 -0700 |
commit | 18eb480eb9fcbaf1c89e76165f370b16e1137d1e (patch) | |
tree | 7da6ea71cf4d4dad0f5cd56417148e58457e96c0 /common/charge_manager.c | |
parent | 78cdc78b0255eef0e36cd1ce611d3e5dd016fc60 (diff) | |
download | chrome-ec-18eb480eb9fcbaf1c89e76165f370b16e1137d1e.tar.gz |
charge_manager: Code cleanup
Check for charge ramp stable only if charge ramp is allowed.
BUG=b:80279932
BRANCH=none
TEST=Manually tested on BIP.
Charge ramp stable check is not called when PD & Type-C
chargers are used.
Change-Id: I4169da3c9f0111a43b490027a297d5cceb5f66e3
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/1123097
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common/charge_manager.c')
-rw-r--r-- | common/charge_manager.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c index ee49210c7e..07af626f5a 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -283,13 +283,7 @@ static void charge_manager_fill_power_info(int port, r->meas.current_max = charge_manager_get_source_current(port); r->max_power = 0; } else { -#if defined(HAS_TASK_CHG_RAMP) || defined(CONFIG_CHARGE_RAMP_HW) - /* Read ramped current if active charging port */ - int use_ramp_current = (charge_port == port); -#else - const int use_ramp_current = 0; -#endif - + int use_ramp_current; switch (sup) { case CHARGE_SUPPLIER_PD: r->type = USB_CHG_TYPE_PD; @@ -333,6 +327,13 @@ static void charge_manager_fill_power_info(int port, CHARGE_DETECT_DELAY) r->type = USB_CHG_TYPE_UNKNOWN; +#if defined(HAS_TASK_CHG_RAMP) || defined(CONFIG_CHARGE_RAMP_HW) + /* Read ramped current if active charging port */ + use_ramp_current = + (charge_port == port) && chg_ramp_allowed(sup); +#else + use_ramp_current = 0; +#endif if (use_ramp_current) { /* Current limit is output of ramp module */ r->meas.current_lim = chg_ramp_get_current_limit(); @@ -346,16 +347,9 @@ static void charge_manager_fill_power_info(int port, * If ramp is not allowed, max current is just the * available charge current. */ - if (chg_ramp_allowed(sup)) { - r->meas.current_max = chg_ramp_is_stable() ? - r->meas.current_lim : - chg_ramp_max( - sup, - available_charge[sup][port].current); - } else { - r->meas.current_max = - available_charge[sup][port].current; - } + r->meas.current_max = chg_ramp_is_stable() ? + r->meas.current_lim : chg_ramp_max(sup, + available_charge[sup][port].current); r->max_power = r->meas.current_max * r->meas.voltage_max; |