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
Avoid resetting charge_max_level during CHG_LIMIT_GET_LIMIT #7
Conversation
board/hx20/battery.c
Outdated
@@ -363,8 +363,9 @@ static enum ec_status cmd_charging_limit_control(struct host_cmd_handler_args *a | |||
charging_maximum_level = charging_maximum_level | CHG_LIMIT_OVERRIDE; | |||
|
|||
if (p->modes & CHG_LIMIT_GET_LIMIT) { | |||
system_get_bbram(SYSTEM_BBRAM_IDX_CHG_MAX, &charging_maximum_level); | |||
r->max_percentage = charging_maximum_level; | |||
uint8_t max = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw I think the code style here is to declare all variables at the beginning of the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair. I was iffy on whether I wanted to introduce a temporary anyway, given that ec_response_chg_limit_control::max_percentage
is itself a uint8_t
. I switched over to reading directly into it.
This may cause a compat problem if the response from this command ever changes, but the correct way to handle that would be with a new command version anyway . . . 😄
Thanks!
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
I'm not certain about the "labeler" failure:
|
Moved this over to |
Reading into
charging_maximum_level
overwritesCHG_LIMIT_OVERRIDE
;GET_LIMIT
should not change global state.Fixes #6.