Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vincent Cloutier" <vincent.cloutier@icloud.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 4/4] dt-bindings: power: supply: max17042: Allow monitored-battery
Date: Mon, 20 Jul 2026 01:21:04 +0000	[thread overview]
Message-ID: <20260720012105.3BBA21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260720011144.1280219-5-vincent.cloutier@icloud.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Infinite retry loop in `max17042_init_worker` on permanent configuration error for MAX17055 devices.
--

--- Patch [4]: [PATCH v2 4/4] dt-bindings: power: supply: max17042: Allow monitored-battery ---
commit 442f6d786e796de83bd68c7855b401281db302f3
Author: Vincent Cloutier <vincent@cloutier.co>

dt-bindings: power: supply: max17042: Allow monitored-battery

The MAX17042 family binding references the generic power-supply schema,
but its additionalProperties restriction means generic properties must
also be admitted explicitly. Allow monitored-battery so these fuel gauges
can reference the physical battery whose characteristics they consume.

> diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
> index 242b33f2bcba5..ace684159e0e2 100644
> --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
> @@ -67,6 +67,8 @@ properties:
>        Voltage threshold to report battery as over voltage (in mV).
>        Default is not to report over-voltage events.
>  
> +  monitored-battery: true
> +

[Severity: High]
Does allowing monitored-battery expose an infinite retry loop in the driver
for MAX17055 devices?

If a MAX17055 device is configured with a voltage-max-design-microvolt >
4.275V but lacks charge-full-design-microamp-hours (or lacks a shunt
resistor), enable_vchg_override is set but config->design_cap remains 0.

During initialization, max17055_override_battery_values() attempts to read
the uninitialized (0) DesignCap and dQAcc registers directly from the
hardware. Since they evaluate to 0, it returns a permanent -ERANGE error:

drivers/power/supply/max17042_battery.c:max17055_override_battery_values() {
...
	ret = regmap_read(map, MAX17042_DesignCap, &design_cap);
...
	if (!design_cap || !dqacc)
		return -ERANGE;
...
}

However, max17042_init_worker() intercepts this error and blindly requeues
the initialization work for MAX17055 devices on any failure:

drivers/power/supply/max17042_battery.c:max17042_init_worker() {
...
	if (ret) {
		if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17055) {
			dev_warn_ratelimited(chip->dev,
				"initialization failed: %d, retrying\n", ret);
			queue_delayed_work(system_freezable_wq, &chip->work,
				msecs_to_jiffies(MAX17055_INIT_RETRY_DELAY_MS));
...
}

Because the hardware registers continually read as 0, this creates an
infinite retry loop triggered by valid, non-malicious device tree
configurations, leading to missing battery status and log spam.

>    power-supplies: true
>  
>  required:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720011144.1280219-1-vincent.cloutier@icloud.com?part=4

  reply	other threads:[~2026-07-20  1:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  1:11 [PATCH v2 0/4] power: supply: initialize MAX17055 from battery info Vincent Cloutier
2026-07-20  1:11 ` [PATCH v2 1/4] power: supply: Add registration init callback Vincent Cloutier
2026-07-20  1:26   ` sashiko-bot
2026-07-20  1:11 ` [PATCH v2 2/4] power: supply: max17042_battery: Initialize MAX17055 from battery info Vincent Cloutier
2026-07-20  1:11 ` [PATCH v2 3/4] power: supply: max17042_battery: Honor MAX17055 charge voltage Vincent Cloutier
2026-07-20  1:11 ` [PATCH v2 4/4] dt-bindings: power: supply: max17042: Allow monitored-battery Vincent Cloutier
2026-07-20  1:21   ` sashiko-bot [this message]
2026-07-20  7:06   ` Krzysztof Kozlowski

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=20260720012105.3BBA21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vincent.cloutier@icloud.com \
    /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