[PATCH] power: supply: bq2515x: Propagate charge-enable read errors

From: Linmao Li

Date: Mon Aug 24 2026 - 04:43:00 EST


bq2515x_get_charge_disable() returns bool even though reading the
charger-disable state can fail. A negative error is therefore converted to
true, so POWER_SUPPLY_PROP_STATUS reports NOT_CHARGING with success instead
of propagating the failure. The GPIO read is not checked for errors either.

Return an int from the helper, check both reads, and only convert a valid
charger-disable state to the charging-status boolean.

Fixes: 44908459275e ("power: supply: bq25150 introduce the bq25150")
Signed-off-by: Linmao Li <lilinmao@xxxxxxxxxx>
---
drivers/power/supply/bq2515x_charger.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c
index 0208358ebbe4c..c2b17562cf8bb 100644
--- a/drivers/power/supply/bq2515x_charger.c
+++ b/drivers/power/supply/bq2515x_charger.c
@@ -420,7 +420,7 @@ static int bq2515x_get_battery_current_now(struct bq2515x_device *bq2515x)
BQ2515X_ICHG_DIVISOR);
}

-static bool bq2515x_get_charge_disable(struct bq2515x_device *bq2515x)
+static int bq2515x_get_charge_disable(struct bq2515x_device *bq2515x)
{
int ret;
int ce_pin;
@@ -428,6 +428,8 @@ static bool bq2515x_get_charge_disable(struct bq2515x_device *bq2515x)
int charger_disable;

ce_pin = gpiod_get_value_cansleep(bq2515x->ce_gpio);
+ if (ce_pin < 0)
+ return ce_pin;

ret = regmap_read(bq2515x->regmap, BQ2515X_ICCTRL2, &icctrl2);
if (ret)
@@ -435,10 +437,7 @@ static bool bq2515x_get_charge_disable(struct bq2515x_device *bq2515x)

charger_disable = icctrl2 & BQ2515X_CHARGER_DISABLE;

- if (charger_disable || ce_pin)
- return true;
-
- return false;
+ return charger_disable || ce_pin;
}

static int bq2515x_set_charge_disable(struct bq2515x_device *bq2515x, int val)
@@ -615,7 +614,11 @@ static int bq2515x_charging_status(struct bq2515x_device *bq2515x,
else
status1_no_fault = false;

- ce_status = (!bq2515x_get_charge_disable(bq2515x));
+ ret = bq2515x_get_charge_disable(bq2515x);
+ if (ret < 0)
+ return ret;
+
+ ce_status = !ret;

/*
* If there are no faults and charging is enabled, then status is

base-commit: 2da28b059e0ddcd2e1956eeae383246207965573
--
2.25.1