diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2021-05-25 18:09:34 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-15 02:40:33 +0000 |
commit | 5323adb2f6349fa605387e30d22ffcb887957f6d (patch) | |
tree | 47f71cc06b28a99ebcac2cd961cf524ca1bacff3 /common | |
parent | db95c62e5f0d057f49109b4f931244cc4c11c58a (diff) | |
download | chrome-ec-5323adb2f6349fa605387e30d22ffcb887957f6d.tar.gz |
chgstv2: Move battery validate code to battery.c
This patch moves the code validating battery parameters to battery.c.
There is no functionality change.
BUG=None
BRANCH=None
TEST=buildall
Change-Id: I1706c4b504565b52964391077894665b4e5d1a86
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3007375
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/battery.c | 23 | ||||
-rw-r--r-- | common/charge_state_v2.c | 20 |
2 files changed, 24 insertions, 19 deletions
diff --git a/common/battery.c b/common/battery.c index ecb1152df1..4670b436b0 100644 --- a/common/battery.c +++ b/common/battery.c @@ -781,3 +781,26 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, reduce_input_voltage_when_full, DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, reduce_input_voltage_when_full, HOOK_PRIO_DEFAULT); #endif + +void battery_validate_params(struct batt_params *batt) +{ + /* + * TODO(crosbug.com/p/27527). Sometimes the battery thinks its + * temperature is 6280C, which seems a bit high. Let's ignore + * anything above the boiling point of tungsten until this bug + * is fixed. If the battery is really that warm, we probably + * have more urgent problems. + */ + if (batt->temperature > CELSIUS_TO_DECI_KELVIN(5660)) { + CPRINTS("ignoring ridiculous batt.temp of %dC", + DECI_KELVIN_TO_CELSIUS(batt->temperature)); + batt->flags |= BATT_FLAG_BAD_TEMPERATURE; + } + + /* If the battery thinks it's above 100%, don't believe it */ + if (batt->state_of_charge > 100) { + CPRINTS("ignoring ridiculous batt.soc of %d%%", + batt->state_of_charge); + batt->flags |= BATT_FLAG_BAD_STATE_OF_CHARGE; + } +} diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index b169bb16f9..cc7dd9094d 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1966,25 +1966,7 @@ void charger_task(void *u) hook_notify(HOOK_BATTERY_SOC_CHANGE); } - /* - * TODO(crosbug.com/p/27527). Sometimes the battery thinks its - * temperature is 6280C, which seems a bit high. Let's ignore - * anything above the boiling point of tungsten until this bug - * is fixed. If the battery is really that warm, we probably - * have more urgent problems. - */ - if (curr.batt.temperature > CELSIUS_TO_DECI_KELVIN(5660)) { - CPRINTS("ignoring ridiculous batt.temp of %dC", - DECI_KELVIN_TO_CELSIUS(curr.batt.temperature)); - curr.batt.flags |= BATT_FLAG_BAD_TEMPERATURE; - } - - /* If the battery thinks it's above 100%, don't believe it */ - if (curr.batt.state_of_charge > 100) { - CPRINTS("ignoring ridiculous batt.soc of %d%%", - curr.batt.state_of_charge); - curr.batt.flags |= BATT_FLAG_BAD_STATE_OF_CHARGE; - } + battery_validate_params(&curr.batt); notify_host_of_over_current(&curr.batt); |