Remove redundant sysfs commit

This commit is contained in:
NGnius (Graham) 2023-04-01 20:18:16 -04:00
parent 0d68ae996c
commit d654e3ee06
2 changed files with 15 additions and 29 deletions

View file

@ -262,15 +262,16 @@ fn print_errors(call_name: &str, errors: Vec<crate::settings::SettingError>) {
impl ApiMessageHandler { impl ApiMessageHandler {
pub fn process_forever(&mut self, settings: &mut Settings) { pub fn process_forever(&mut self, settings: &mut Settings) {
let mut dirty_echo = true; // set everything twice, to make sure PowerTools wins on race conditions //let mut dirty_echo = true; // set everything twice, to make sure PowerTools wins on race conditions
while let Ok(msg) = self.intake.recv() { while let Ok(msg) = self.intake.recv() {
let mut dirty = self.process(settings, msg); let mut dirty = self.process(settings, msg);
while let Ok(msg) = self.intake.try_recv() { while let Ok(msg) = self.intake.try_recv() {
dirty |= self.process(settings, msg); dirty |= self.process(settings, msg);
} }
if dirty || dirty_echo { if dirty /*|| dirty_echo */ {
dirty_echo = dirty; // echo only once //dirty_echo = dirty; // echo only once
// run on_set
// run on_set
if let Err(e) = settings.on_set() { if let Err(e) = settings.on_set() {
print_errors("on_set", e); print_errors("on_set", e);
} }

View file

@ -300,14 +300,6 @@ impl Cpu {
setting: crate::settings::SettingVariant::Cpu, setting: crate::settings::SettingVariant::Cpu,
}) })
.unwrap_or_else(|e| errors.push(e)); .unwrap_or_else(|e| errors.push(e));
usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n").unwrap_or_else(
|e| {
errors.push(SettingError {
msg: format!("Failed to write `c` to `{}`: {}", CPU_CLOCK_LIMITS_PATH, e),
setting: crate::settings::SettingVariant::Cpu,
});
},
);
} else if self.state.clock_limits_set } else if self.state.clock_limits_set
|| (self.state.is_resuming && !self.limits.skip_resume_reclock) || (self.state.is_resuming && !self.limits.skip_resume_reclock)
|| POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.needs_manual() || POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.needs_manual()
@ -339,17 +331,6 @@ impl Cpu {
setting: crate::settings::SettingVariant::Cpu, setting: crate::settings::SettingVariant::Cpu,
}) })
.unwrap_or_else(|e| errors.push(e)); .unwrap_or_else(|e| errors.push(e));
usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n").unwrap_or_else(
|e| {
errors.push(SettingError {
msg: format!(
"Failed to write `c` to `{}`: {}",
CPU_CLOCK_LIMITS_PATH, e
),
setting: crate::settings::SettingVariant::Cpu,
});
},
);
} }
POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_cpu(false, self.index); POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_cpu(false, self.index);
POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT
@ -358,12 +339,16 @@ impl Cpu {
} }
// commit changes (if no errors have already occured) // commit changes (if no errors have already occured)
if errors.is_empty() { if errors.is_empty() {
usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n").map_err(|e| { if POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.needs_manual() {
vec![SettingError { usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n").map_err(|e| {
msg: format!("Failed to write `c` to `{}`: {}", CPU_CLOCK_LIMITS_PATH, e), vec![SettingError {
setting: crate::settings::SettingVariant::Cpu, msg: format!("Failed to write `c` to `{}`: {}", CPU_CLOCK_LIMITS_PATH, e),
}] setting: crate::settings::SettingVariant::Cpu,
}) }]
})
} else {
Ok(())
}
} else { } else {
Err(errors) Err(errors)
} }