Skip to content

Commit 8ffc2f9

Browse files
Merge pull request #57 from quatquatt/cap-charge-limit
charge_limit: cap percentage to 100%
2 parents cc8d1ef + 3bd173b commit 8ffc2f9

File tree

1 file changed

+5
-1
lines changed
  • framework_lib/src/commandline

1 file changed

+5
-1
lines changed

framework_lib/src/commandline/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,11 +1163,15 @@ pub fn analyze_capsule(data: &[u8]) -> Option<capsule::EfiCapsuleHeader> {
11631163
fn handle_charge_limit(ec: &CrosEc, maybe_limit: Option<u8>) -> EcResult<()> {
11641164
let (cur_min, _cur_max) = ec.get_charge_limit()?;
11651165
if let Some(limit) = maybe_limit {
1166-
// Prevent accidentally setting a very low limit
1166+
// Prevent setting unreasonable limits
11671167
if limit < 25 {
11681168
return Err(EcError::DeviceError(
11691169
"Not recommended to set charge limit below 25%".to_string(),
11701170
));
1171+
} else if limit > 100 {
1172+
return Err(EcError::DeviceError(
1173+
"Charge limit cannot be set above 100%".to_string(),
1174+
));
11711175
}
11721176
ec.set_charge_limit(cur_min, limit)?;
11731177
}

0 commit comments

Comments
 (0)