summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2023-04-06 15:21:49 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-12 01:53:06 +0000
commit2bdcb5c97baec99ef308279c487b5c68f8912324 (patch)
treeaf9a19e009a19470fc838f0964ae29c348f5e011
parenteeff2ef395c8b6af3be88b71b4671a1f41702d08 (diff)
downloadchrome-ec-2bdcb5c97baec99ef308279c487b5c68f8912324.tar.gz
charge_manager: don't refer to ramp functions if disabled
Although preprocessor guards for charge ramp support were used to determine whether current should be ramped, this still depended on the compiler to optimize out references to chg_ramp_get_current_limit() in the no-ramp configuration. Such optimizations cannot be depended on when building unit tests, so lift the conditional branches that use ramp-related functions into the preprocessor conditional blocks. BUG=b:276805061,b:267959470 TEST=Zephyr unit tests no longer fail to link with undefined references to chg_ramp_get_current_limit and friends. BRANCH=none Change-Id: Ic17c690cd4bab5f51b31597023824fbbc7dcd4d5 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4402422 Reviewed-by: Tristan Honscheid <honscheid@google.com>
-rw-r--r--common/charge_manager.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c
index fe374810aa..198c1ef301 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -467,7 +467,6 @@ charge_manager_fill_power_info(int port,
board_fill_source_power_info(port, r);
}
} else {
- int use_ramp_current;
uint32_t max_mv, max_ma, pdo, unused;
switch (sup) {
@@ -540,13 +539,7 @@ charge_manager_fill_power_info(int port,
#endif
#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(port, sup);
-#else
- use_ramp_current = 0;
-#endif
- if (use_ramp_current) {
+ if ((charge_port == port) && chg_ramp_allowed(port, sup)) {
/* Current limit is output of ramp module */
r->meas.current_lim = chg_ramp_get_current_limit();
@@ -563,10 +556,12 @@ charge_manager_fill_power_info(int port,
chg_ramp_is_stable() ?
r->meas.current_lim :
chg_ramp_max(port, sup, max_ma);
-
} else {
r->meas.current_max = r->meas.current_lim = max_ma;
}
+#else
+ r->meas.current_max = r->meas.current_lim = max_ma;
+#endif
r->max_power = r->meas.current_max * r->meas.voltage_max;
r->meas.voltage_now = get_vbus_voltage(port, r->role);