power: supply: bq27xxx: bug fixes
Subsystems (4)
v2 cover power: supply: bq27xxx: bug fixes
PATCH V2 2025-08-23 12:33:18:
Changes:
* improved commit description of main fix
* new patch: adds a restriction of historical no-battery-detection logic to the bq27000 chip
PATCH V1 2025-07-21 14:46:09:
H. Nikolaus Schaller (2):
power: supply: bq27xxx: fix error return in case of no bq27000 hdq
battery
power: supply: bq27xxx: restrict no-battery detection to bq27000
drivers/power/supply/bq27xxx_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.50.1
PATCH v2 1/2 power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
Since commit
commit f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")
the console log of some devices with hdq enabled but no bq27000 battery (like e.g. 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 by
commit 3dd843e1c26a ("bq27000: report missing device better.")to constant -1 which did make reading properties return -ENODEV. So everything appeared to be fine before the return value was passed upwards.
Now the -1 is returned as -EPERM 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.
---
Notes:
Changes to v1:
* improved commit description of main fix
drivers/power/supply/bq27xxx_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/bq27xxx_battery.c +1 -1
@@ -1945,7 +1945,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);
Signature · 1 line
2.50.1
PATCH v2 2/2 power: supply: bq27xxx: restrict no-battery detection to bq27000
In reply to H. Nikolaus SchallerThere are fuel gauges in the bq27xxx series (e.g. bq27z561) which may in some cases report 0xff as the value of BQ27XXX_REG_FLAGS that should not be interpreted as "no battery" like for a disconnected battery with some built in bq27000 chip.
So restrict the no-battery detection originally introduced by
commit 3dd843e1c26a ("bq27000: report missing device better.")to the bq27000.
There is no need to backport further because this was hidden before
commit f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")
--- drivers/power/supply/bq27xxx_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/bq27xxx_battery.c +2 -2
@@ -1944,8 +1944,8 @@ static void bq27xxx_battery_update_unlocked(struct bq27xxx_device_info *di)bool has_singe_flag = di->opts &BQ27XXX_O_ZERO ; cache.flags =bq27xxx_read (di,BQ27XXX_REG_FLAGS , has_singe_flag); -if ((cache.flags &0xff ) ==0xff ) - cache.flags = -ENODEV ;/* read error */ +if (di->chip ==BQ27000 && (cache.flags &0xff ) ==0xff ) + cache.flags = -ENODEV ;/* bq27000 hdq read error */ if (cache.flags >=0 ) { cache.capacity =bq27xxx_battery_read_soc (di);
Signature · 1 line
2.50.1
Re: [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
In reply to H. Nikolaus Schaller…
Quoted 1 line
So we change the detection of missing bq27000 battery to simply set
…
Regards,
Markus
Re: [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
Quoted 10 lines · Markus Elfring
…
Quoted 1 line
So we change the detection of missing bq27000 battery to simply set
…
Regards,
Markus
Hi,
This is the semi-friendly patch-bot of Greg Kroah-Hartman.
Markus, you seem to have sent a nonsensical or otherwise pointless review comment to a patch submission on a Linux kernel developer mailing list. I strongly suggest that you not do this anymore. Please do not bother developers who are actively working to produce patches and features with comments that, in the end, are a waste of time.
Patch submitter, please ignore Markus's suggestion; you do not need to follow it at all. The person/bot/AI that sent it is being ignored by almost all Linux kernel maintainers for having a persistent pattern of behavior of producing distracting and pointless commentary, and inability to adapt to feedback. Please feel free to also ignore emails from them.
thanks,
greg k-h's patch email bot
Re: [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000
In reply to H. Nikolaus SchallerQuoted 28 lines · H. Nikolaus Schaller
There are fuel gauges in the bq27xxx series (e.g. bq27z561) which may in some cases report
0xffas the value ofBQ27XXX_REG_FLAGSthat should not be interpreted as "no battery" like for a disconnected battery with some built in bq27000 chip.So restrict the no-battery detection originally introduced by
commit 3dd843e1c26a ("bq27000: report missing device better.")to the bq27000.
There is no need to backport further because this was hidden before
commit
f16d9fb6cf03("power: supply: bq27xxx: Retrieve again when busy")Fixes f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")Suggested-by Jerry Lv <[email protected]>Signed-off-by H. Nikolaus Schaller <[email protected]>--- drivers/power/supply/bq27xxx_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/power/supply/bq27xxx_battery.c +0
-0
drivers/power/supply/bq27xxx_battery.c static void bq27xxx_battery_update_unlocked(struct bq27xxx_device_info *di) · line 1951
Quoted 10 lines
drivers/power/supply/bq27xxx_battery.c +2
-2@@ -1944,8 +1944,8 @@ static void bq27xxx_battery_update_unlocked(struct bq27xxx_device_info *di)bool has_singe_flag = di->opts &BQ27XXX_O_ZERO ; cache.flags =bq27xxx_read (di,BQ27XXX_REG_FLAGS , has_singe_flag); -if ((cache.flags &0xff ) ==0xff ) - cache.flags = -ENODEV ;/* read error */ +if (di->chip ==BQ27000 && (cache.flags &0xff ) ==0xff ) + cache.flags = -ENODEV ;/* bq27000 hdq read error */ if (cache.flags >=0 ) { cache.capacity =bq27xxx_battery_read_soc (di);
This change works fine for BQ27z561
Re: [Letux-kernel] [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000
Quoted 28 lines
Am 28.08.2025 um 09:33 schrieb Jerry Lv <[email protected]>:
Quoted 23 lines · H. Nikolaus Schaller
There are fuel gauges in the bq27xxx series (e.g. bq27z561) which may in some cases report
0xffas the value ofBQ27XXX_REG_FLAGSthat should not be interpreted as "no battery" like for a disconnected battery with some built in bq27000 chip.So restrict the no-battery detection originally introduced by
commit 3dd843e1c26a ("bq27000: report missing device better.")to the bq27000.
There is no need to backport further because this was hidden before
commit
f16d9fb6cf03("power: supply: bq27xxx: Retrieve again when busy")Fixes f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")Suggested-by Jerry Lv <[email protected]>Signed-off-by H. Nikolaus Schaller <[email protected]>--- drivers/power/supply/bq27xxx_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
drivers/power/supply/bq27xxx_battery.c +0
-0drivers/power/supply/bq27xxx_battery.c static void bq27xxx_battery_update_unlocked(struct bq27xxx_device_info *di) · line 1950
Quoted 9 lines
drivers/power/supply/bq27xxx_battery.c +2
-2@@ -1944,8 +1944,8 @@ static void bq27xxx_battery_update_unlocked(struct bq27xxx_device_info *di)bool has_singe_flag = di->opts &BQ27XXX_O_ZERO ; cache.flags =bq27xxx_read (di,BQ27XXX_REG_FLAGS , has_singe_flag); -if ((cache.flags &0xff ) ==0xff ) - cache.flags = -ENODEV ;/* read error */ +if (di->chip ==BQ27000 && (cache.flags &0xff ) ==0xff ) + cache.flags = -ENODEV ;/* bq27000 hdq read error */ if (cache.flags >=0 ) { cache.capacity =bq27xxx_battery_read_soc (di);This change works fine for BQ27z561
Thanks for testing!
So it appears we need a maintainer to pick up these patches...
BR,
Nikolaus
Am Sat, 23 Aug 2025 12:34:55 +0200
schrieb "H. Nikolaus Schaller" <[email protected]>:
Quoted 5 lines
PATCH V2 2025-08-23 12:33:18:
Changes:
* improved commit description of main fix
* new patch: adds a restriction of historical no-battery-detection logic to the bq27000 chip
Quoted 8 lines
PATCH V1 2025-07-21 14:46:09:
H. Nikolaus Schaller (2):
power: supply: bq27xxx: fix error return in case of no bq27000 hdq
battery
power: supply: bq27xxx: restrict no-battery detection to bq27000
hmm, is the order correct? To me to be bisectable, should it be turned around? Maybe Sebastian just can do that while picking it.
Regards,
Andreas
Quoted 15 lines
Am 28.08.2025 um 20:24 schrieb Andreas Kemnade <[email protected]>:
Am Sat, 23 Aug 2025 12:34:55 +0200
schrieb "H. Nikolaus Schaller" <[email protected]>:Quoted 8 lines
PATCH V2 2025-08-23 12:33:18:
Changes:
* improved commit description of main fix
* new patch: adds a restriction of historical no-battery-detection logic to the bq27000 chipPATCH V1 2025-07-21 14:46:09:
Quoted 7 lines
Quoted 5 lines
H. Nikolaus Schaller (2):
power: supply: bq27xxx: fix error return in case of no bq27000 hdq
battery
power: supply: bq27xxx: restrict no-battery detection to bq27000hmm, is the order correct? To me to be bisectable, should it be turned around? Maybe Sebastian just can do that while picking it.
Well, it is to decide which of the two fuel gauges fix first...
The bq27000 is working again after the first one and the bq27z561 is no longer influenced after the second.
BR,
Nikolaus
Sebastian Reichel
AppliedQuoted 8 lines · H. Nikolaus Schaller
PATCH V2 2025-08-23 12:33:18:
Changes:
* improved commit description of main fix
* new patch: adds a restriction of historical no-battery-detection logic to the bq27000 chipPATCH V1 2025-07-21 14:46:09:
[...]
Applied, thanks!
[1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
commit: 2c334d038466ac509468fbe06905a32d202117db
[2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000
commit: 1e451977e1703b6db072719b37cd1b8e250b9cc9Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>