Devicetree
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Prachoday Sutar <prachodaysutar7@gmail.com>, <sre@kernel.org>,
	<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<pali@kernel.org>
Cc: <linux-pm@vger.kernel.org>, <devicetree@vger.kernel.org>
Subject: Re: [PATCH v2 0/2] Add TI BQ27Z558 fuel gauge support
Date: Fri, 27 Nov 2026 10:43:00 -0600	[thread overview]
Message-ID: <314807f4-dedf-496a-b4e0-d034ac97ade3@ti.com> (raw)
In-Reply-To: <20261126201959.28743-1-prachodaysutar7@gmail.com>

On 11/26/26 2:19 PM, Prachoday Sutar wrote:
> The TI BQ27Z558 is a single-cell fuel gauge documented in the same
> Technical Reference Manual as the BQ27Z561-R2 (SLUUC54) and is register
> compatible with the BQ27Z561.
> 
> Patch 1 adds the compatible to the binding with "ti,bq27z561" as the
> fallback. Patch 2 adds a matching I2C device ID so the driver probes
> correctly when the client is named after the first compatible.
> 
> Tested on a Kneron KL630-based board with a BQ27Z558, using a vendor
> Linux 4.9 kernel with the equivalent bq27xxx changes and the fallback
> compatible in DT. Voltage, current, capacity, status and temperature
> read correctly through /sys/class/power_supply.
> 
> Changes in v2:
> - Add patch 2. Binding via the fallback compatible alone left
>    i2c_client_get_device_id() returning NULL in probe, causing a NULL
>    pointer dereference (reported by the Sashiko AI review).

I thought you said you tested this with the fallback? And Sashiko
says fallback will cause a NULL dereference, one of these must not
be true then..

I can see what Sashiko might be talking about here. I think a
couple things need fixed.

First, the `bq27xxx_battery_i2c_of_match_table` and the
`bq27xxx_i2c_id_table` are out of sync, so we match with OF
compatible, but use the I2C ID table to get the mach data.
The OF match data is currently empty, that needs updated.

Second, `i2c_client_get_device_id()` is only used as we need to
fetch the name, but we only use the name in `request_threaded_irq()`,
and we could use `client->name` instead. Then for getting the match
data use `i2c_get_match_data()`.

Third, I'd just skip the fallback stuff. If you have to modify the
driver anyway, just add a normal compatible and use it in your DT.

Andrew

> - Patch 1: drop the claim from the commit message that no driver
>    changes are needed.
> 
> Link to v1: https://lore.kernel.org/r/20261126191906.25708-1-prachodaysutar7@gmail.com
> 
> Prachoday Sutar (2):
>    dt-bindings: power: supply: bq27xxx: Add BQ27Z558
>    power: supply: bq27xxx: Add BQ27Z558 I2C device ID
> 
>   .../bindings/power/supply/bq27xxx.yaml        | 72 ++++++++++---------
>   drivers/power/supply/bq27xxx_battery_i2c.c    |  1 +
>   2 files changed, 39 insertions(+), 34 deletions(-)
> 


      parent reply	other threads:[~2026-11-27 16:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 20:19 [PATCH v2 0/2] Add TI BQ27Z558 fuel gauge support Prachoday Sutar
2026-11-26 20:19 ` [PATCH v2 1/2] dt-bindings: power: supply: bq27xxx: Add BQ27Z558 Prachoday Sutar
2026-11-26 20:19 ` [PATCH v2 2/2] power: supply: bq27xxx: Add BQ27Z558 I2C device ID Prachoday Sutar
2026-11-27 16:43 ` Andrew Davis [this message]

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=314807f4-dedf-496a-b4e0-d034ac97ade3@ti.com \
    --to=afd@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=prachodaysutar7@gmail.com \
    --cc=robh@kernel.org \
    --cc=sre@kernel.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