summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-06-29 10:33:02 -0700
committerCommit Bot <commit-bot@chromium.org>2022-02-21 07:48:54 +0000
commit62aa7e97ce86e1beb3b41a5232402b83fa41a6f9 (patch)
tree5ff6e6ec188c84ce106a4a1074577e86d59d6478 /common
parent036335469b08329fb9bd93865340c12f2bf3d991 (diff)
downloadchrome-ec-62aa7e97ce86e1beb3b41a5232402b83fa41a6f9.tar.gz
Battery: Apply fake SoC to display charge
This patch makes the battfake command apply the fake SoC to the display SoC as well as the raw battery SoC. This patch also cleans up battery_compensate_params. BUG=None BRANCH=None TEST=Atlas Change-Id: Ifbdaa81204d27501df8a4f5e025c19a79d62feff Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2994748 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3340214 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3469845
Diffstat (limited to 'common')
-rw-r--r--common/battery.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/common/battery.c b/common/battery.c
index 50d689f0d1..7e0baf6986 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -577,18 +577,18 @@ void battery_compensate_params(struct batt_params *batt)
{
int numer, denom;
int *remain = &(batt->remaining_capacity);
- int *full = &(batt->full_capacity);
+ int full = batt->full_capacity;
if ((batt->flags & BATT_FLAG_BAD_FULL_CAPACITY) ||
(batt->flags & BATT_FLAG_BAD_REMAINING_CAPACITY))
return;
- if (*remain <= 0 || *full <= 0)
+ if (*remain <= 0 || full <= 0)
return;
/* Some batteries don't update full capacity as often. */
- if (*remain > *full)
- *remain = *full;
+ if (*remain > full)
+ *remain = full;
/*
* EC calculates the display SoC like how Powerd used to do. Powerd
@@ -611,8 +611,8 @@ void battery_compensate_params(struct batt_params *batt)
* = ----------------------------------- x 1000
* full x (full_factor - shutdown_pct)
*/
- numer = 1000 * ((100 * *remain) - (*full * batt_host_shutdown_pct));
- denom = *full * (batt_host_full_factor - batt_host_shutdown_pct);
+ numer = 1000 * ((100 * *remain) - (full * batt_host_shutdown_pct));
+ denom = full * (batt_host_full_factor - batt_host_shutdown_pct);
/* Rounding (instead of truncating) */
batt->display_charge = (numer + denom / 2) / denom;
if (batt->display_charge < 0)