]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ACPI: battery: negate current when discharging
authorPeter Marheine <pmarheine@chromium.org>
Thu, 8 May 2025 02:41:45 +0000 (12:41 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:32 +0000 (11:07 +0100)
commit616f53db01c3fbb11928a9afa18ca66ac4b82c2c
treee2d582f48b7d68c5ee35d4c5fa7bf84c0381ea0a
parentc272bafb0a67d46b7bfa29c133cb3a6191785e96
ACPI: battery: negate current when discharging

[ Upstream commit 234f71555019d308c6bc6f98c78c5551cb8cd56a ]

The ACPI specification requires that battery rate is always positive,
but the kernel ABI for POWER_SUPPLY_PROP_CURRENT_NOW
(Documentation/ABI/testing/sysfs-class-power) specifies that it should
be negative when a battery is discharging. When reporting CURRENT_NOW,
massage the value to match the documented ABI.

This only changes the sign of `current_now` and not `power_now` because
documentation doesn't describe any particular meaning for `power_now` so
leaving `power_now` unchanged is less likely to confuse userspace
unnecessarily, whereas becoming consistent with the documented ABI is
worth potentially confusing clients that read `current_now`.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Link: https://patch.msgid.link/20250508024146.1436129-1-pmarheine@chromium.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/acpi/battery.c