]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: supply: max17042: time to empty is meaningless when charging
authorAndré Draszik <andre.draszik@linaro.org>
Mon, 2 Mar 2026 13:32:06 +0000 (13:32 +0000)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 3 Mar 2026 22:58:07 +0000 (23:58 +0100)
When charging, the fuel gauge reports U16_MAX as time to empty.
Ignoring this special case (as this driver currently does), causes the
remaining time to be reported as ~102hours, which is incorrect.

Update the code to not return anything in this case.

Reviewed-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
Link: https://patch.msgid.link/20260302-max77759-fg-v3-7-3c5f01dbda23@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/max17042_battery.c

index 39091fb317119d478e556084166d7a1da8d4efe7..0a6960bbf3a29c458abc25abae660a3f48b38bbb 100644 (file)
@@ -430,6 +430,10 @@ static int max17042_get_property(struct power_supply *psy,
                if (ret < 0)
                        return ret;
 
+               /* when charging, the value is not meaningful */
+               if (data == U16_MAX)
+                       return -ENODATA;
+
                val->intval = data * 5625 / 1000;
                break;
        default: