[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <yfbgbdugk4xdjpemozdzcuxczx4xd5aphykuksf3lhn22dsgkf@fcfgddu6gpyt>
Date: Fri, 14 Feb 2025 00:24:18 +0200
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: aruhier@...lbox.org
Cc: Sebastian Reichel <sre@...nel.org>, linux-arm-msm@...r.kernel.org,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND] power: supply: qcom_battmgr: abs() on POWER_NOW
property
On Thu, Feb 13, 2025 at 05:51:38PM +0100, Anthony Ruhier via B4 Relay wrote:
> From: Anthony Ruhier <aruhier@...lbox.org>
>
> The value for the POWER_NOW property is by default negative when the
> battery is discharging, positive when charging.
>
> However on x1e laptops it breaks several userland tools that give a
> prediction of the battery run time (such as the acpi command, powertop
> or the waybar battery module), as these tools do not expect a negative
> value for /sys/class/power_supply/qcom-battmgr-bat/power_now. They
> estimate the battery run time by dividing the value of energy_full by
> power_now. The battery percentage is calculated by dividing energy_full
> by energy_now, therefore it is not impacted.
>
> While having a negative number during discharge makes sense, it is not
> standard with how other battery drivers expose it. Instead, it seems
> standard to have a positive value for power_now, and rely on the status
> file instead to know if the battery is charging or discharging. It is
> what other x86 laptops do.
Documentation/ABI does not define ABI for the power_now. However for
current_now it clearly defines that it can be positive or negative.
>
> Without the patch:
> $ acpi
> Battery 0: Discharging, 98%, discharging at zero rate - will never fully discharge.
>
> With the patch:
> $ acpi
> Battery 0: Discharging, 97%, 10:18:27 remaining
>
> ---
> Signed-off-by: Anthony Ruhier <aruhier@...lbox.org>
> ---
> drivers/power/supply/qcom_battmgr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
--
With best wishes
Dmitry
Powered by blists - more mailing lists