[PATCH] ACPI: battery: add state_of_health support to power_supply

From: luoxueqin

Date: Thu Apr 23 2026 - 03:59:11 EST


From: Xueqin Luo <luoxueqin@xxxxxxxxxx>

Add support for POWER_SUPPLY_PROP_STATE_OF_HEALTH in ACPI battery
driver.

State of Health is calculated as the ratio between full charge capacity
and design capacity, expressed as a percentage.

The value is computed as:
SOH = full_charge_capacity * 100 / design_capacity

Only valid ACPI battery capacity values are used for the calculation.
If either full charge capacity or design capacity is not available,
the property returns -ENODEV.

Signed-off-by: Xueqin Luo <luoxueqin@xxxxxxxxxx>
---
drivers/acpi/battery.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b4c25474f42f..6e6396aad2c8 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -267,6 +267,15 @@ static int acpi_battery_get_property(struct power_supply *psy,
else
val->intval = battery->full_charge_capacity * 1000;
break;
+ case POWER_SUPPLY_PROP_STATE_OF_HEALTH:
+ if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) ||
+ !ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity))
+ return -ENODEV;
+
+ full_capacity = battery->full_charge_capacity;
+ val->intval = DIV_ROUND_CLOSEST_ULL(full_capacity * 100ULL,
+ battery->design_capacity);
+ break;
case POWER_SUPPLY_PROP_CHARGE_NOW:
case POWER_SUPPLY_PROP_ENERGY_NOW:
if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
@@ -323,6 +332,7 @@ static const enum power_supply_property charge_battery_props[] = {
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CHARGE_FULL,
+ POWER_SUPPLY_PROP_STATE_OF_HEALTH,
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
@@ -355,6 +365,7 @@ static const enum power_supply_property energy_battery_props[] = {
POWER_SUPPLY_PROP_POWER_NOW,
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
POWER_SUPPLY_PROP_ENERGY_FULL,
+ POWER_SUPPLY_PROP_STATE_OF_HEALTH,
POWER_SUPPLY_PROP_ENERGY_NOW,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
--
2.43.0