From 2eb29bb25fc2de1be45eb24c5678664b82a1dabf Mon Sep 17 00:00:00 2001 From: Caveh Jalali Date: Fri, 18 May 2018 15:20:20 -0700 Subject: [PATCH] atlas: ignore unavailable battery temp readings the battery temperature field is only valid after we've actually managed to read the battery temperatore parameter. so, if the temp field is marked "BAD", don't even look at it. this addresses a case where we were removing charge current during the precharge phase - basically removing charge current from a battery that we're trying to power so we can talk to its I2C controller. BUG=b:79354967 BRANCH=none TEST=instrumented code to verify we don't request 0 amps in ST_PRECHARGE Change-Id: I3b40903506fa949c14ecaf577f134f31cfcf8fb7 Signed-off-by: Caveh Jalali Reviewed-on: https://chromium-review.googlesource.com/1066789 Commit-Ready: Caveh Jalali Tested-by: Caveh Jalali Reviewed-by: Daisuke Nojiri --- board/atlas/battery.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/board/atlas/battery.c b/board/atlas/battery.c index d764367d0c..dd9cde9d5c 100644 --- a/board/atlas/battery.c +++ b/board/atlas/battery.c @@ -160,8 +160,12 @@ int charger_profile_override(struct charge_state_data *curr) { const struct battery_info *batt_info; /* battery temp in 0.1 deg C */ - int bat_temp_c = curr->batt.temperature - 2731; + int bat_temp_c; + if (curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE) + return 0; + + bat_temp_c = curr->batt.temperature - 2731; batt_info = battery_get_info(); /* Don't charge if outside of allowable temperature range */ if (bat_temp_c >= batt_info->charging_max_c * 10 ||