From: "André Draszik" <andre.draszik@linaro.org>
To: Hans de Goede <hansg@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>,
Purism Kernel Team <kernel@puri.sm>,
Sebastian Reichel <sre@kernel.org>,
Rob Herring <robh@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: "Peter Griffin" <peter.griffin@linaro.org>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>,
"Juan Yescas" <jyescas@google.com>,
"Amit Sunil Dhamne" <amitsd@google.com>,
kernel-team@android.com, linux-pm@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
"André Draszik" <andre.draszik@linaro.org>
Subject: [PATCH v2 07/11] power: supply: max17042: time to empty is meaningless when charging
Date: Fri, 27 Feb 2026 07:15:12 +0000 [thread overview]
Message-ID: <20260227-max77759-fg-v2-7-e50be5f191f0@linaro.org> (raw)
In-Reply-To: <20260227-max77759-fg-v2-0-e50be5f191f0@linaro.org>
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@linaro.org>
---
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.473.g4a7958ca14-goog
next prev parent reply other threads:[~2026-02-27 7:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 7:15 [PATCH v2 00/11] power: supply: max17042: support Maxim MAX77759 fuel gauge André Draszik
2026-02-27 7:15 ` [PATCH v2 01/11] dt-bindings: power: supply: max17042: add support for max77759 André Draszik
2026-02-27 7:15 ` [PATCH v2 02/11] dt-bindings: power: supply: max17042: support shunt-resistor-micro-ohms André Draszik
2026-02-27 7:15 ` [PATCH v2 03/11] dt-bindings: power: supply: max17042: drop formatting specifier | André Draszik
2026-02-27 7:15 ` [PATCH v2 04/11] power: supply: max17042: fix a comment typo (then -> than) André Draszik
2026-02-27 7:15 ` [PATCH v2 05/11] power: supply: max17042: use dev_err_probe() where appropriate André Draszik
2026-02-27 7:15 ` [PATCH v2 06/11] power: supply: max17042: avoid overflow when determining health André Draszik
2026-02-27 7:15 ` André Draszik [this message]
2026-02-27 16:47 ` [PATCH v2 07/11] power: supply: max17042: time to empty is meaningless when charging Peter Griffin
2026-02-27 7:15 ` [PATCH v2 08/11] power: supply: max17042: support standard shunt-resistor-micro-ohms DT property André Draszik
2026-02-27 16:07 ` Peter Griffin
2026-02-27 7:15 ` [PATCH v2 09/11] power: supply: max17042: initial support for Maxim MAX77759 André Draszik
2026-02-27 17:00 ` Peter Griffin
2026-02-27 7:15 ` [PATCH v2 10/11] power: supply: max17042: consider task period (max77759) André Draszik
2026-02-27 17:01 ` Peter Griffin
2026-02-27 7:15 ` [PATCH v2 11/11] power: supply: max17042: report time to full (max17055 & max77759) André Draszik
2026-02-27 16:53 ` Peter Griffin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260227-max77759-fg-v2-7-e50be5f191f0@linaro.org \
--to=andre.draszik@linaro.org \
--cc=amitsd@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hansg@kernel.org \
--cc=jyescas@google.com \
--cc=kernel-team@android.com \
--cc=kernel@puri.sm \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=peter.griffin@linaro.org \
--cc=robh@kernel.org \
--cc=sebastian.krzyszkowiak@puri.sm \
--cc=sre@kernel.org \
--cc=tudor.ambarus@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®