]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Revert "power: supply: bq27xxx: do not report bogus zero values"
authorSicelo A. Mhlongo <absicsz@gmail.com>
Wed, 12 Mar 2025 12:14:08 +0000 (14:14 +0200)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 17 Mar 2025 14:53:59 +0000 (15:53 +0100)
Commit f3974aca381e ("power: supply: bq27xxx: do not report bogus zero
values") breaks property reporting on chips which are reporting normal
values. During testing, excessive emphasis was evidently placed on the
chip with non-working conditions, and not enough testing was done on a
battery that had normal state.

A correct fix will be submitted in a separate patch.

Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Closes: https://lore.kernel.org/linux-pm/CB5B8FE7-D619-4D30-BD2D-58B6CEF83D46@goldelico.com/
Fixes: f3974aca381e ("power: supply: bq27xxx: do not report bogus zero values")
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
Link: https://lore.kernel.org/r/20250312121712.146109-2-absicsz@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/bq27xxx_battery.c

index 1789167c68e3126e2c391d8b17161f6da051f7c3..2f31d750a4c1e3fe4273e9a010936e7446bee9ea 100644 (file)
@@ -2148,10 +2148,6 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
                break;
        case POWER_SUPPLY_PROP_CAPACITY:
                ret = bq27xxx_simple_value(di->cache.capacity, val);
-               /* If 0 is reported, it is expected that EDVF is also set */
-               if (!ret && di->opts & BQ27XXX_O_ZERO &&
-                  !(di->cache.flags & BQ27000_FLAG_EDVF))
-                       return -EINVAL;
                break;
        case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
                ret = bq27xxx_battery_capacity_level(di, val);
@@ -2175,15 +2171,10 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
                        val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
                break;
        case POWER_SUPPLY_PROP_CHARGE_NOW:
-               if (di->regs[BQ27XXX_REG_NAC] != INVALID_REG_ADDR) {
+               if (di->regs[BQ27XXX_REG_NAC] != INVALID_REG_ADDR)
                        ret = bq27xxx_battery_read_nac(di, val);
-                       /* If 0 is reported, it is expected that EDVF is also set */
-                       if (!ret && di->opts & BQ27XXX_O_ZERO &&
-                          !(di->cache.flags & BQ27000_FLAG_EDVF))
-                               return -EINVAL;
-               } else {
+               else
                        ret = bq27xxx_battery_read_rc(di, val);
-               }
                break;
        case POWER_SUPPLY_PROP_CHARGE_FULL:
                ret = bq27xxx_battery_read_fcc(di, val);
@@ -2208,10 +2199,6 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
                break;
        case POWER_SUPPLY_PROP_ENERGY_NOW:
                ret = bq27xxx_battery_read_energy(di, val);
-               /* If 0 is reported, it is expected that EDVF is also set */
-               if (!ret && di->opts & BQ27XXX_O_ZERO &&
-                  !(di->cache.flags & BQ27000_FLAG_EDVF))
-                       return -EINVAL;
                break;
        case POWER_SUPPLY_PROP_POWER_AVG:
                ret = bq27xxx_battery_pwr_avg(di, val);