[PATCH 07/11] power: supply: max17042: time to empty is meaningless when charging
From: André Draszik
Date: Thu Feb 26 2026 - 08:15:17 EST
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.
Signed-off-by: André Draszik <andre.draszik@xxxxxxxxxx>
---
drivers/power/supply/max17042_battery.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 8808c0d2ad10..bae0670e2496 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -434,6 +434,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:
--
2.53.0.414.gf7e9f6c205-goog