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
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
> 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
© 2016 - 2025 Red Hat, Inc.