]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Revert "ACPI: battery: negate current when discharging"
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 3 Jul 2025 10:54:55 +0000 (12:54 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 3 Jul 2025 11:00:11 +0000 (13:00 +0200)
Revert commit 234f71555019 ("ACPI: battery: negate current when
discharging") breaks not one but several userspace implementations
of battery monitoring: Steam and MangoHud. Perhaps it breaks more,
but those are the two that have been tested.

Reported-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Closes: https://lore.kernel.org/linux-acpi/87C1B2AF-D430-4568-B620-14B941A8ABA4@linux.dev/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/battery.c

index 45593612a4db96260728ccad9009970c34c543d5..6905b56bf3e4580f2fb137e0a1101e13a47591d5 100644 (file)
@@ -243,23 +243,10 @@ static int acpi_battery_get_property(struct power_supply *psy,
                break;
        case POWER_SUPPLY_PROP_CURRENT_NOW:
        case POWER_SUPPLY_PROP_POWER_NOW:
-               if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) {
+               if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
                        ret = -ENODEV;
-                       break;
-               }
-
-               val->intval = battery->rate_now * 1000;
-               /*
-                * When discharging, the current should be reported as a
-                * negative number as per the power supply class interface
-                * definition.
-                */
-               if (psp == POWER_SUPPLY_PROP_CURRENT_NOW &&
-                   (battery->state & ACPI_BATTERY_STATE_DISCHARGING) &&
-                   acpi_battery_handle_discharging(battery)
-                               == POWER_SUPPLY_STATUS_DISCHARGING)
-                       val->intval = -val->intval;
-
+               else
+                       val->intval = battery->rate_now * 1000;
                break;
        case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
        case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: