[PATCH 1/3] power: supply: bq27xxx: report discharging at zero current without a charger
From: Michael Auer
Date: Sat Nov 21 2026 - 15:41:50 EST
The status is derived from the sign of the current, so a current of 0
is reported as "Not charging". On a OnePlus 6 (bq27541) the first
current reading after a resume from deep sleep is 0. User space then
sees "Not charging" while on battery: UPower no longer reports the
device as on battery, and the desktop plays its "power adapter plugged
in" sound after such resumes, until the next reading shows a negative
current again.
"Not charging" means a charger is present but not charging, so report
"Discharging" for a zero current when no power supply is online. Do it
only for the direct property read: the cached update runs under
di->lock, and power_supply_is_system_supplied() also reads properties
of this battery.
Signed-off-by: Michael Auer <mick@xxxxxxxx>
---
drivers/power/supply/bq27xxx_battery.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 747a38d3390d..032eea030f2f 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1942,6 +1942,14 @@ static int bq27xxx_battery_current_and_status(
val_status->intval = POWER_SUPPLY_STATUS_CHARGING;
else if (curr < 0)
val_status->intval = POWER_SUPPLY_STATUS_DISCHARGING;
+ else if (!cache && power_supply_is_system_supplied() == 0)
+ /*
+ * No charger online: |current| is below the resolution (e.g. after
+ * deep sleep). Only for the direct property read: the cached update
+ * runs under di->lock, and power_supply_is_system_supplied() calls
+ * get_property() on every supply, this battery included.
+ */
+ val_status->intval = POWER_SUPPLY_STATUS_DISCHARGING;
else
val_status->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
}
--
2.43.0