@@ -407,12 +407,16 @@ static bool cpcap_battery_full(struct cpcap_battery_ddata *ddata)
struct cpcap_battery_state_data *state = cpcap_battery_latest(ddata);
static bool is_full;
- if (state->voltage >=
- (ddata->config.bat.constant_charge_voltage_max_uv - 18000) &&
- state->current_ua > (is_full ? -150000 : -100000))
- is_full = true;
- else
+ if (state->voltage <
+ (ddata->config.bat.constant_charge_voltage_max_uv - 18000)) {
is_full = false;
+ } else if (is_full) {
+ if (state->current_ua < -150000)
+ is_full = false;
+ } else if (state->current_ua >= -150000 &&
+ cpcap_battery_cc_get_avg_current(ddata) >= -100000) {
+ is_full = true;
+ }
return is_full;
}
Use average current when detecting the fully charged state Signed-off-by: Arthur Demchenkov <spinal.by@gmail.com> --- drivers/power/supply/cpcap-battery.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)