Devicetree
 help / color / mirror / Atom feed
* [PATCH] dt-bindings: power: supply: bq27xxx: Add BQ27Z558
@ 2026-11-26 19:19 Prachoday Sutar
  2026-11-26 19:25 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Prachoday Sutar @ 2026-11-26 19:19 UTC (permalink / raw)
  To: sre, robh, krzk+dt, conor+dt, pali, afd
  Cc: linux-pm, devicetree, Prachoday Sutar

The TI BQ27Z558 is a single-cell fuel gauge documented in the same
Technical Reference Manual as the BQ27Z561-R2 (SLUUC54). It uses the
same standard command set and register layout as the BQ27Z561, which
is already supported by the bq27xxx driver.

Add a compatible for the BQ27Z558 with "ti,bq27z561" as the fallback,
so the existing driver binds without any code changes.

Signed-off-by: Prachoday Sutar <prachodaysutar7@gmail.com>
---
Tested on a Kneron KL630-based board with a BQ27Z558, using a vendor
Linux 4.9 kernel with the upstream BQ27Z561 support backported to
bq27xxx. Voltage, current, capacity, status and temperature read
correctly through /sys/class/power_supply.

 .../bindings/power/supply/bq27xxx.yaml        | 72 ++++++++++---------
 1 file changed, 38 insertions(+), 34 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
index be0f1f729..28b04732e 100644
--- a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
+++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
@@ -18,40 +18,44 @@ description: |
 
 properties:
   compatible:
-    enum:
-      - ti,bq27200
-      - ti,bq27210
-      - ti,bq27500 # deprecated, use revision specific property below
-      - ti,bq27510 # deprecated, use revision specific property below
-      - ti,bq27520 # deprecated, use revision specific property below
-      - ti,bq27500-1
-      - ti,bq27510g1
-      - ti,bq27510g2
-      - ti,bq27510g3
-      - ti,bq27520g1
-      - ti,bq27520g2
-      - ti,bq27520g3
-      - ti,bq27520g4
-      - ti,bq27521
-      - ti,bq27530
-      - ti,bq27531
-      - ti,bq27541
-      - ti,bq27542
-      - ti,bq27546
-      - ti,bq27742
-      - ti,bq27545
-      - ti,bq27411
-      - ti,bq27421
-      - ti,bq27425
-      - ti,bq27426
-      - ti,bq27441
-      - ti,bq27621
-      - ti,bq27z561
-      - ti,bq27z746
-      - ti,bq28z610
-      - ti,bq28z620
-      - ti,bq34z100
-      - ti,bq78z100
+    oneOf:
+      - enum:
+          - ti,bq27200
+          - ti,bq27210
+          - ti,bq27500 # deprecated, use revision specific property below
+          - ti,bq27510 # deprecated, use revision specific property below
+          - ti,bq27520 # deprecated, use revision specific property below
+          - ti,bq27500-1
+          - ti,bq27510g1
+          - ti,bq27510g2
+          - ti,bq27510g3
+          - ti,bq27520g1
+          - ti,bq27520g2
+          - ti,bq27520g3
+          - ti,bq27520g4
+          - ti,bq27521
+          - ti,bq27530
+          - ti,bq27531
+          - ti,bq27541
+          - ti,bq27542
+          - ti,bq27546
+          - ti,bq27742
+          - ti,bq27545
+          - ti,bq27411
+          - ti,bq27421
+          - ti,bq27425
+          - ti,bq27426
+          - ti,bq27441
+          - ti,bq27621
+          - ti,bq27z561
+          - ti,bq27z746
+          - ti,bq28z610
+          - ti,bq28z620
+          - ti,bq34z100
+          - ti,bq78z100
+      - items:
+          - const: ti,bq27z558
+          - const: ti,bq27z561
 
   reg:
     maxItems: 1
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dt-bindings: power: supply: bq27xxx: Add BQ27Z558
  2026-11-26 19:19 [PATCH] dt-bindings: power: supply: bq27xxx: Add BQ27Z558 Prachoday Sutar
@ 2026-11-26 19:25 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26 19:25 UTC (permalink / raw)
  To: Prachoday Sutar; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] dt-bindings: power: supply: bq27xxx: NULL deref in
  bq27xxx_battery_i2c_probe()
--

commit 54d1a3afdd53a67243b18d9017c27b2cdf3485cd
Author: Prachoday Sutar <prachodaysutar7@gmail.com>

dt-bindings: power: supply: bq27xxx: Add BQ27Z558

This commit adds the "ti,bq27z558" compatible string to the bq27xxx fuel
gauge device tree binding with "ti,bq27z561" as a fallback.

> diff --git a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
> index be0f1f7292c8f..28b04732e08d9 100644
> --- a/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
> @@ -18,40 +18,44 @@ description: |
>  
>  properties:
>    compatible:

[ ... ]

> +      - items:
> +          - const: ti,bq27z558
> +          - const: ti,bq27z561
>  
>    reg:
>      maxItems: 1

[Severity: High]
Does binding via the "ti,bq27z561" fallback trigger a NULL pointer
dereference in bq27xxx_battery_i2c_probe()?

When the I2C core creates the client from Device Tree,
of_i2c_get_board_info() -> of_alias_from_compatible() populates
client->name from the first compatible string ("bq27z558").  During probe,
bq27xxx_battery_i2c_of_match_table matches the "ti,bq27z561" fallback, but
its entries do not set .data:

drivers/power/supply/bq27xxx_battery_i2c.c:bq27xxx_battery_i2c_probe() {
	const struct i2c_device_id *id = i2c_client_get_device_id(client);
	...
	name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%ld", id->name, num);
	...
	di->chip = id->driver_data;
}

Because "bq27z558" is not in bq27xxx_i2c_id_table,
i2c_client_get_device_id(client) returns NULL and probe crashes
dereferencing id->name and id->driver_data.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126191906.25708-1-prachodaysutar7@gmail.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-26 19:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 19:19 [PATCH] dt-bindings: power: supply: bq27xxx: Add BQ27Z558 Prachoday Sutar
2026-11-26 19:25 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox