Skip to content

fix(thresholds): reorder write operations to avoid firmware rejection…#9

Open
MatiM72737 wants to merge 1 commit into
vietanhdev:mainfrom
MatiM72737:bugfix/battery-thresholds
Open

fix(thresholds): reorder write operations to avoid firmware rejection…#9
MatiM72737 wants to merge 1 commit into
vietanhdev:mainfrom
MatiM72737:bugfix/battery-thresholds

Conversation

@MatiM72737

Copy link
Copy Markdown

Fixes "Invalid argument" when setting battery charge thresholds

The firmware rejects writes to charge_control_end_threshold if it would temporarily make start ≥ stop.

Solution

  • Read current thresholds before changing
  • If lowering the stop threshold (new_stop < current_start), write new start first, then new stop
  • Otherwise, write new stop first, then new start

Tested on

  • Model: t495s (r5 3500U)
  • Kernel: 6.18.9.zen1-2
  • Works for both increasing and decreasing thresholds

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.

1 participant