diff mbox series

[2/2] power: supply: bq256xx: Add ability to omit battery class

Message ID 20240907-bq256xx-omit-battery-class-v1-2-45f6d8dbd1e5@mainlining.org (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series Add omit-battery-class property for bq256xxx | expand

Commit Message

Barnabás Czémán Sept. 7, 2024, 11:07 a.m. UTC
Add omit-battery-class property to avoid make a battery device
for charger when fg makes one.

Signed-off-by: Barnabás Czémán <barnabas.czeman@mainlining.org>
---
 drivers/power/supply/bq256xx_charger.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
index 5514d1896bb8..62721d564b39 100644
--- a/drivers/power/supply/bq256xx_charger.c
+++ b/drivers/power/supply/bq256xx_charger.c
@@ -1547,12 +1547,14 @@  static int bq256xx_power_supply_init(struct bq256xx_device *bq,
 		return PTR_ERR(bq->charger);
 	}
 
-	bq->battery = devm_power_supply_register(bq->dev,
-						      &bq256xx_battery_desc,
-						      psy_cfg);
-	if (IS_ERR(bq->battery)) {
-		dev_err(dev, "power supply register battery failed\n");
-		return PTR_ERR(bq->battery);
+	if (!device_property_read_bool(dev, "omit-battery-class")) {
+		bq->battery = devm_power_supply_register(bq->dev,
+							 &bq256xx_battery_desc,
+							 psy_cfg);
+		if (IS_ERR(bq->battery)) {
+			dev_err(dev, "power supply register battery failed\n");
+			return PTR_ERR(bq->battery);
+		}
 	}
 	return 0;
 }