diff options
author | Philip Chen <philipchen@chromium.org> | 2018-11-20 07:46:23 +0000 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-11-20 07:49:16 +0000 |
commit | b3049f1774998110e96db862364f185ffc148382 (patch) | |
tree | ba7cc2470474e792f70be753b832d9b05639160d | |
parent | a04fd75d825bc33077abfd15822b29f9d53bd34c (diff) | |
download | chrome-ec-b3049f1774998110e96db862364f185ffc148382.tar.gz |
Revert "max17055: Invalidate all batt info when batt not present."
This reverts commit 319ae8c6240f698574163388a197b0b24b9d66db.
Reason for revert: It's probably not a good ideas to clear battery params every time battery_get_params() is called. Otherwise funky things may happen - see the bug links.
BUG=b:119322063, b:73347743
Original change's description:
> max17055: Invalidate all batt info when batt not present.
>
> BUG=b:117061273
> TEST=on kukui, remove batt, connect pd, see battery output in console
> > battery
> Status: 0x0000
> Param flags:000007fc
> Temp: 0x0000 = 0.0 K (-273.1 C)
> V: 0x0000 = 0 mV
> V-desired: 0x0000 = 0 mV
> I: 0x0000 = 0 mA
> I-desired: 0x0000 = 0 mA
> Charging: Not Allowed
> Charge: 0 %
> Manuf: <unkn>
> Device: <BATT>
> Chem: <unkn>
> Serial: 0xffffffff
> V-design: 0x0f14 = 3860 mV
> Mode: (unsupported)
> Abs charge:(unsupported)
> Remaining: 6334 mAh
> Cap-full: 6910 mAh
> Design: 6910 mAh
> Time-full: 0h:0
> Empty: 102h:23
> TEST=on connect batt, connect pd, see battery output in console
> BRANCH=None
>
> Change-Id: Ied338266fa0f7713da408438460bc97d4db01e6f
> Signed-off-by: Yilun Lin <yllin@google.com>
> Reviewed-on: https://chromium-review.googlesource.com/1253372
> Commit-Ready: Yilun Lin <yllin@chromium.org>
> Tested-by: Yilun Lin <yllin@chromium.org>
> Reviewed-by: Philip Chen <philipchen@chromium.org>
> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
> (cherry picked from commit fbb47e2bc63c1b84e1509b50e2169018a2701364)
> Reviewed-on: https://chromium-review.googlesource.com/c/1311513
> Commit-Queue: Philip Chen <philipchen@chromium.org>
> Tested-by: Philip Chen <philipchen@chromium.org>
> Trybot-Ready: Philip Chen <philipchen@chromium.org>
Bug: b:117061273
Change-Id: I0750cc43ff7de1940675b969c9243ce55fe3ba46
Reviewed-on: https://chromium-review.googlesource.com/c/1342735
Reviewed-by: Philip Chen <philipchen@chromium.org>
Commit-Queue: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Trybot-Ready: Philip Chen <philipchen@chromium.org>
-rw-r--r-- | driver/battery/max17055.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/driver/battery/max17055.c b/driver/battery/max17055.c index 07ecc473dd..db8b798a3b 100644 --- a/driver/battery/max17055.c +++ b/driver/battery/max17055.c @@ -264,19 +264,8 @@ void battery_get_params(struct batt_params *batt) { int reg = 0; - /* Reset params */ - memset(batt, 0, sizeof(struct batt_params)); - /* - * Assuming the battery is responsive as long as - * max17055 finds battery is present. - */ - batt->is_present = battery_is_present(); - - if (batt->is_present == BP_YES) - batt->flags |= BATT_FLAG_RESPONSIVE; - else if (batt->is_present == BP_NO) - /* Battery is not present, gauge won't report useful info. */ - return; + /* Reset flags */ + batt->flags = 0; if (max17055_read(REG_TEMPERATURE, ®)) batt->flags |= BATT_FLAG_BAD_TEMPERATURE; @@ -310,6 +299,15 @@ void battery_get_params(struct batt_params *batt) batt->flags |= BATT_FLAG_BAD_FULL_CAPACITY; /* + * Assuming the battery is responsive as long as + * max17055 finds battery is present. + */ + batt->is_present = battery_is_present(); + + if (batt->is_present == BP_YES) + batt->flags |= BATT_FLAG_RESPONSIVE; + + /* * Charging allowed if both desired voltage and current are nonzero * and battery isn't full (and we read them all correctly). */ |