If we hit battery low once, we should stick on reporting it until the charger is connected. This way low->counter_uah will be updated properly, and that will allow us to get more accurate charge_full value. Signed-off-by: Arthur Demchenkov <spinal.by@xxxxxxxxx> --- drivers/power/supply/cpcap-battery.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 52f03a2662a5..8a58ad943960 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -421,11 +421,14 @@ static bool cpcap_battery_full(struct cpcap_battery_ddata *ddata) static bool cpcap_battery_low(struct cpcap_battery_ddata *ddata) { struct cpcap_battery_state_data *state = cpcap_battery_latest(ddata); + static bool is_low; - if (state->current_ua && state->voltage <= 3300000) - return true; + if (state->current_ua > 0 && (state->voltage <= 3300000 || is_low)) + is_low = true; + else + is_low = false; - return false; + return is_low; } static int cpcap_battery_update_status(struct cpcap_battery_ddata *ddata) -- 2.11.0