* [PATCH v2 0/2] power: supply: bq27xxx: bug fixes
@ 2025-08-23 10:34 H. Nikolaus Schaller
2025-08-23 10:34 ` [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery H. Nikolaus Schaller
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: H. Nikolaus Schaller @ 2025-08-23 10:34 UTC (permalink / raw)
To: Sebastian Reichel, Jerry Lv
Cc: Pali Rohár, linux-pm, linux-kernel, letux-kernel, stable,
kernel, andreas, 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 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(-)
--
2.50.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
2025-08-23 10:34 [PATCH v2 0/2] power: supply: bq27xxx: bug fixes H. Nikolaus Schaller
@ 2025-08-23 10:34 ` H. Nikolaus Schaller
2025-08-23 14:46 ` Markus Elfring
2025-08-23 10:34 ` [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000 H. Nikolaus Schaller
2025-08-28 18:24 ` [PATCH v2 0/2] power: supply: bq27xxx: bug fixes Andreas Kemnade
2 siblings, 1 reply; 9+ messages in thread
From: H. Nikolaus Schaller @ 2025-08-23 10:34 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 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.
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>
---
Notes:
Changes to v1:
* improved commit description of main fix
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 c3616b1c07e6f..dadd8754a73a8 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -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);
--
2.50.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000
2025-08-23 10:34 [PATCH v2 0/2] power: supply: bq27xxx: bug fixes H. Nikolaus Schaller
2025-08-23 10:34 ` [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery H. Nikolaus Schaller
@ 2025-08-23 10:34 ` H. Nikolaus Schaller
2025-08-28 7:33 ` Jerry Lv
2025-08-28 18:24 ` [PATCH v2 0/2] power: supply: bq27xxx: bug fixes Andreas Kemnade
2 siblings, 1 reply; 9+ messages in thread
From: H. Nikolaus Schaller @ 2025-08-23 10:34 UTC (permalink / raw)
To: Sebastian Reichel, Jerry Lv
Cc: Pali Rohár, linux-pm, linux-kernel, letux-kernel, stable,
kernel, andreas, H. Nikolaus Schaller
There 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")
Fixes: f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")
Suggested-by: 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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index dadd8754a73a8..3363af24017ae 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -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);
--
2.50.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
2025-08-23 10:34 ` [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery H. Nikolaus Schaller
@ 2025-08-23 14:46 ` Markus Elfring
2025-08-23 14:54 ` Greg KH
0 siblings, 1 reply; 9+ messages in thread
From: Markus Elfring @ 2025-08-23 14:46 UTC (permalink / raw)
To: H. Nikolaus Schaller, linux-pm, kernel, letux-kernel, Jerry Lv,
Sebastian Reichel
Cc: stable, LKML, Andreas Kemnade, Pali Rohár
…
> So we change the detection of missing bq27000 battery to simply set
…
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc2#n94
Regards,
Markus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery
2025-08-23 14:46 ` Markus Elfring
@ 2025-08-23 14:54 ` Greg KH
0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2025-08-23 14:54 UTC (permalink / raw)
To: Markus Elfring
Cc: H. Nikolaus Schaller, linux-pm, kernel, letux-kernel, Jerry Lv,
Sebastian Reichel, stable, LKML, Andreas Kemnade, Pali Rohár
On Sat, Aug 23, 2025 at 04:46:46PM +0200, Markus Elfring wrote:
> …
> > So we change the detection of missing bq27000 battery to simply set
> …
>
> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc2#n94
>
> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000
2025-08-23 10:34 ` [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000 H. Nikolaus Schaller
@ 2025-08-28 7:33 ` Jerry Lv
2025-08-28 11:45 ` [Letux-kernel] " H. Nikolaus Schaller
0 siblings, 1 reply; 9+ messages in thread
From: Jerry Lv @ 2025-08-28 7:33 UTC (permalink / raw)
To: H. Nikolaus Schaller, Sebastian Reichel, Jerry Lv
Cc: Pali Rohár, linux-pm, linux-kernel, letux-kernel, stable,
kernel, andreas
On 8/23/2025 6:34 PM, H. Nikolaus Schaller wrote:
> There 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")
>
> Fixes: f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")
> Suggested-by: 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 | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index dadd8754a73a8..3363af24017ae 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Letux-kernel] [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000
2025-08-28 7:33 ` Jerry Lv
@ 2025-08-28 11:45 ` H. Nikolaus Schaller
0 siblings, 0 replies; 9+ messages in thread
From: H. Nikolaus Schaller @ 2025-08-28 11:45 UTC (permalink / raw)
To: Discussions about the Letux Kernel
Cc: Sebastian Reichel, Jerry Lv, linux-pm, linux-kernel, stable,
kernel, Pali Rohár, Discussions about the Letux Kernel,
Andreas Kemnade
> Am 28.08.2025 um 09:33 schrieb Jerry Lv <jerrylv@axis.com>:
>
> On 8/23/2025 6:34 PM, H. Nikolaus Schaller wrote:
>> There 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")
>>
>> Fixes: f16d9fb6cf03 ("power: supply: bq27xxx: Retrieve again when busy")
>> Suggested-by: 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 | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
>> index dadd8754a73a8..3363af24017ae 100644
>> --- a/drivers/power/supply/bq27xxx_battery.c
>> +++ b/drivers/power/supply/bq27xxx_battery.c
>> @@ -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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/2] power: supply: bq27xxx: bug fixes
2025-08-23 10:34 [PATCH v2 0/2] power: supply: bq27xxx: bug fixes H. Nikolaus Schaller
2025-08-23 10:34 ` [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery H. Nikolaus Schaller
2025-08-23 10:34 ` [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000 H. Nikolaus Schaller
@ 2025-08-28 18:24 ` Andreas Kemnade
2025-08-28 20:11 ` H. Nikolaus Schaller
2 siblings, 1 reply; 9+ messages in thread
From: Andreas Kemnade @ 2025-08-28 18:24 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Sebastian Reichel, Jerry Lv, Pali Rohár, linux-pm,
linux-kernel, letux-kernel, stable, kernel
Am Sat, 23 Aug 2025 12:34:55 +0200
schrieb "H. Nikolaus Schaller" <hns@goldelico.com>:
> 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
>
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/2] power: supply: bq27xxx: bug fixes
2025-08-28 18:24 ` [PATCH v2 0/2] power: supply: bq27xxx: bug fixes Andreas Kemnade
@ 2025-08-28 20:11 ` H. Nikolaus Schaller
0 siblings, 0 replies; 9+ messages in thread
From: H. Nikolaus Schaller @ 2025-08-28 20:11 UTC (permalink / raw)
To: Andreas Kemnade
Cc: Sebastian Reichel, Jerry Lv, Pali Rohár, linux-pm,
linux-kernel, letux-kernel, stable, kernel
> Am 28.08.2025 um 20:24 schrieb Andreas Kemnade <andreas@kemnade.info>:
>
> Am Sat, 23 Aug 2025 12:34:55 +0200
> schrieb "H. Nikolaus Schaller" <hns@goldelico.com>:
>
>> 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
>>
> hmm, 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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-08-28 20:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-23 10:34 [PATCH v2 0/2] power: supply: bq27xxx: bug fixes H. Nikolaus Schaller
2025-08-23 10:34 ` [PATCH v2 1/2] power: supply: bq27xxx: fix error return in case of no bq27000 hdq battery H. Nikolaus Schaller
2025-08-23 14:46 ` Markus Elfring
2025-08-23 14:54 ` Greg KH
2025-08-23 10:34 ` [PATCH v2 2/2] power: supply: bq27xxx: restrict no-battery detection to bq27000 H. Nikolaus Schaller
2025-08-28 7:33 ` Jerry Lv
2025-08-28 11:45 ` [Letux-kernel] " H. Nikolaus Schaller
2025-08-28 18:24 ` [PATCH v2 0/2] power: supply: bq27xxx: bug fixes Andreas Kemnade
2025-08-28 20:11 ` 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).