Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: battery runtime estimation with negative sysfs values #3942

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

aruhier
Copy link
Contributor

@aruhier aruhier commented Feb 16, 2025

Some drivers (example: qualcomm-battmgr, present on Snapdragon X1 laptops) expose the current_now and power_now values in sysfs as negative int when the device is discharging, positive when charging.

This breaks the battery runtime estimation in Waybar, as it expects a uint32 for power_now.
Change the battery module to use the absolute values of current_now and power_now.

I discussed about it with the maintainer of qualcomm-battmgr, and the conclusion has been that it's better to fix the userland tools to respect the ABI documentation for current_now (which specifies negative values when discharging), and allows for negative values for power_now: https://lore.kernel.org/linux-arm-msm/20250213-patch-qcomm-bat-uint-power-v1-1-16e7e2a77a02@mailbox.org/

Some drivers (example: qualcomm-battmgr, present on Snapdragon X1
laptops) expose the current_now and power_now values in sysfs as
negative int when the device is discharging, positive when charging.

This breaks the battery runtime estimation in Waybar, as it expects a
uint32 for power_now.

Change the battery module to use the absolute values of current_now and
power_now.
@Alexays Alexays merged commit 533d5de into Alexays:master Feb 20, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants