linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
@ 2025-07-21 12:46 H. Nikolaus Schaller
  2025-08-05  8:53 ` Jerry Lv
  2025-08-21 18:15 ` Andreas Kemnade
  0 siblings, 2 replies; 11+ messages in thread
From: H. Nikolaus Schaller @ 2025-07-21 12:46 UTC (permalink / raw)
  To: Sebastian Reichel, Jerry Lv
  Cc: Pali Rohár, linux-pm, linux-kernel, letux-kernel, stable,
	kernel, andreas, H. Nikolaus Schaller

Since commit

commit f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")

the console log of some devices with hdq but no bq27000 battery
(like the Pandaboard) is flooded with messages like:

[   34.247833] power_supply bq27000-battery: driver failed to report 'status' property: -1

as soon as user-space is finding a /sys entry and trying to read the
"status" property.

It turns out that the offending commit changes the logic to now return the
value of cache.flags if it is <0. This is likely under the assumption that
it is an error number. In normal errors from bq27xxx_read() this is indeed
the case.

But there is special code to detect if no bq27000 is installed or accessible
through hdq/1wire and wants to report this. In that case, the cache.flags
are set (historically) to constant -1 which did make reading properties
return -ENODEV. So everything appeared to be fine before the return value was
fixed. Now the -1 is returned as -ENOPERM instead of -ENODEV, triggering the
error condition in power_supply_format_property() which then floods the
console log.

So we change the detection of missing bq27000 battery to simply set

	cache.flags = -ENODEV

instead of -1.

Fixes: f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")
Cc: Jerry Lv <Jerry.Lv@axis.com>
Cc: stable@vger.kernel.org
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/power/supply/bq27xxx_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index 93dcebbe11417..efe02ad695a62 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1920,7 +1920,7 @@ static void bq27xxx_battery_update_unlocked(struct bq27xxx_device_info *di)
 
 	cache.flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag);
 	if ((cache.flags & 0xff) == 0xff)
-		cache.flags = -1; /* read error */
+		cache.flags = -ENODEV; /* read error */
 	if (cache.flags >= 0) {
 		cache.capacity = bq27xxx_battery_read_soc(di);
 
-- 
2.50.0


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

end of thread, other threads:[~2025-08-23 10:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 12:46 [PATCH] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery H. Nikolaus Schaller
2025-08-05  8:53 ` Jerry Lv
2025-08-05  9:28   ` H. Nikolaus Schaller
2025-08-08  9:13     ` Jerry Lv
2025-08-21 17:55       ` H. Nikolaus Schaller
2025-08-23 10:31   ` H. Nikolaus Schaller
2025-08-21 18:15 ` Andreas Kemnade
2025-08-21 18:54   ` H. Nikolaus Schaller
2025-08-21 20:05     ` Andreas Kemnade
2025-08-22  6:51       ` H. Nikolaus Schaller
2025-08-22 13:00         ` H. Nikolaus Schaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).