power: supply: qcom_battmgr: Report battery capacity
authorKornel Dulęba <korneld@google.com>
Wed, 28 May 2025 11:23:29 +0000 (11:23 +0000)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sun, 22 Jun 2025 00:54:46 +0000 (02:54 +0200)
commit3f87baacea4d185071655f9b0baf07abb6237fcd
tree43205bb6d92be11777788fa58bc5a640b4c0fbcb
parent6aa1c3a72b99abeb7ddc649047073d701ede2c91
power: supply: qcom_battmgr: Report battery capacity

Battery charge can be reported in several different ways. One of them is
is charge percentage referred to as POWER_SUPPLY_PROP_CAPACITY in the
power supply API. Currently the driver reports the capacity in this way
on SM8350, but not on the newer variants referred to as SC8280XP in the
driver. Although this is not a bug in itself, not reporting the
percentage can confuse some userspace consumers.
Mimic what is done in the ACPI driver (drivers/acpi/battery.c) and
calculate the percentage capacity by dividing the current charge value
by the full charge.

Signed-off-by: Kornel Dulęba <korneld@google.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250528112328.1640743-2-korneld@google.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/qcom_battmgr.c