diff options
-rw-r--r-- | common/battery.c | 12 | ||||
-rw-r--r-- | driver/battery/smart.c | 1 |
2 files changed, 7 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) diff --git a/driver/battery/smart.c b/driver/battery/smart.c index a017f0ba96..f30b74d71b 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -335,6 +335,7 @@ static void apply_fake_state_of_charge(struct batt_params *batt) batt->state_of_charge = fake_state_of_charge; batt->remaining_capacity = full * fake_state_of_charge / 100; + battery_compensate_params(batt); batt->flags &= ~BATT_FLAG_BAD_STATE_OF_CHARGE; batt->flags &= ~BATT_FLAG_BAD_REMAINING_CAPACITY; } |