Linux Power Management development
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Prachoday Sutar <prachodaysutar7@gmail.com>
Cc: Andrew Davis <afd@ti.com>,
	robh@kernel.org, krzk+dt@kernel.org,  conor+dt@kernel.org,
	pali@kernel.org, linux-pm@vger.kernel.org,
	 devicetree@vger.kernel.org
Subject: Re: [PATCH v2 0/2] Add TI BQ27Z558 fuel gauge support
Date: Sat, 5 Dec 2026 19:37:05 +0100	[thread overview]
Message-ID: <axRYaLqodDak3LTE@venus> (raw)
In-Reply-To: <CAPE1b8XVOmBtyocoyXAnLQZY62xunSJEFvVtj=2SJsauG+jhEw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2714 bytes --]

Hi,

On Sun, Nov 29, 2026 at 07:55:18PM +0530, Prachoday Sutar wrote:
> On Fri, Nov 27, 2026, Andrew Davis wrote:
> > 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..
> 
> You're right, the test note was wrong, sorry about that. The testing
> was done on a vendor 4.9 kernel with a local backport of BQ27Z561
> support, and the board DT used only "ti,bq27z558", not the fallback.
> In that tree "bq27z558" was in both the I2C ID table and the OF match
> table, so the I2C ID lookup succeeded and the fallback-only path that
> Sashiko flagged was never exercised. So that test only shows that the
> BQ27Z558 works with the BQ27Z561 register map and status bits; it did
> not run the mainline driver. I'll describe the testing accurately in
> v3.
>
> > 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.
> 
> Agreed. In v3 I'll add the chip type as .data to every entry in the
> OF match table, so the two tables no longer need to be kept in sync
> by hand.
> 
> > 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()`.
> 
> Will do. For all existing compatibles client->name is the same as the
> matched I2C ID name, so the battery names seen by userspace don't
> change.
> 
> > 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.
> 
> OK, I'll drop the fallback and add "ti,bq27z558" as a plain
> compatible, which also matches how it was set up in the tree I tested.

The fallback is the correct thing to do. The binding is not just
for the Linux driver and the only reason the Linux driver needs
the specific entry is the exact chip name.

> One question first: once the OF match data is in place, the
> fallback would work without any BQ27Z558-specific driver change.
> If the DT binding maintainers would prefer to keep the fallback
> for that reason, I'm happy to do that instead. Otherwise I'll go
> with the plain compatible.
>
> 
> Planned v3:
>   1/3 dt-bindings: power: supply: bq27xxx: Add BQ27Z558
>   2/3 power: supply: bq27xxx: Use i2c_get_match_data()
>   3/3 power: supply: bq27xxx: Add BQ27Z558 support
> 
> Thanks,
> Prachoday

Greetings,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-12-05 18:37 UTC|newest]

Thread overview: 6+ 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 ` [PATCH v2 0/2] Add TI BQ27Z558 fuel gauge support Andrew Davis
2026-11-29 14:25   ` Prachoday Sutar
2026-12-05 18:37     ` Sebastian Reichel [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=axRYaLqodDak3LTE@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=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 \
    /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