summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2020-08-03 16:12:09 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-13 17:33:30 +0000
commit9fdb85f84a3a5b964597de7cc1822be42ad9c462 (patch)
tree11c5b6ed7b337c2c795741ed16337970310b0fcd
parenta7d87f78e4efcbf2158a1a69be1327d6e727a4db (diff)
downloadchrome-ec-9fdb85f84a3a5b964597de7cc1822be42ad9c462.tar.gz
battery: Remove redundant lfcc variable when calculate compensation
The value of lfcc variable, which is copied from host_get_memmap(EC_MEMMAP_BATT_LFCC), is actually the compensated full capacity. Use the value of *full directly. BRANCH=None BUG=b:162604872 TEST=Checked the battery console command result. Change-Id: Iae103dd325679333c524698ce7a86cdc96a3587e Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2335885 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872706 Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/battery.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/common/battery.c b/common/battery.c
index ab9a1a359b..4d8d962c3a 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -567,7 +567,6 @@ void battery_compensate_params(struct batt_params *batt)
int numer, denom;
int *remain = &(batt->remaining_capacity);
int *full = &(batt->full_capacity);
- int lfcc = *(int *)host_get_memmap(EC_MEMMAP_BATT_LFCC);
if ((batt->flags & BATT_FLAG_BAD_FULL_CAPACITY) ||
(batt->flags & BATT_FLAG_BAD_REMAINING_CAPACITY))
@@ -583,19 +582,16 @@ void battery_compensate_params(struct batt_params *batt)
/* full_factor is effectively disabled in powerd. */
*full = *full * batt_full_factor / 100;
- if (lfcc == 0)
- /* EC just reset. Assume host full is equal. */
- lfcc = *full;
- if (*remain > lfcc)
- *remain = lfcc;
+ if (*remain > *full)
+ *remain = *full;
/*
* Powerd uses the following equation to calculate display percentage:
* charge = 100 * remain/full;
* 100 * (charge - shutdown_pct) / (full_factor - shutdown_pct);
*/
- numer = (100 * *remain - lfcc * batt_host_shutdown_pct) * 1000;
- denom = lfcc * (100 - batt_host_shutdown_pct);
+ numer = (100 * *remain - *full * batt_host_shutdown_pct) * 1000;
+ denom = *full * (100 - batt_host_shutdown_pct);
/* Rounding (instead of truncating) */
batt->display_charge = (numer + denom / 2) / denom;
if (batt->display_charge < 0)