From d654e3ee06a4915534eb91c4b7daec1f99499a35 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 1 Apr 2023 20:18:16 -0400 Subject: [PATCH] Remove redundant sysfs commit --- backend/src/api/handler.rs | 9 ++++--- backend/src/settings/steam_deck/cpu.rs | 35 ++++++++------------------ 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/backend/src/api/handler.rs b/backend/src/api/handler.rs index 0b947ad..d44afb9 100644 --- a/backend/src/api/handler.rs +++ b/backend/src/api/handler.rs @@ -262,15 +262,16 @@ fn print_errors(call_name: &str, errors: Vec) { impl ApiMessageHandler { 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() { let mut dirty = self.process(settings, msg); while let Ok(msg) = self.intake.try_recv() { dirty |= self.process(settings, msg); } - if dirty || dirty_echo { - dirty_echo = dirty; // echo only once - // run on_set + if dirty /*|| dirty_echo */ { + //dirty_echo = dirty; // echo only once + + // run on_set if let Err(e) = settings.on_set() { print_errors("on_set", e); } diff --git a/backend/src/settings/steam_deck/cpu.rs b/backend/src/settings/steam_deck/cpu.rs index 4b641f1..91ec128 100644 --- a/backend/src/settings/steam_deck/cpu.rs +++ b/backend/src/settings/steam_deck/cpu.rs @@ -300,14 +300,6 @@ impl Cpu { setting: crate::settings::SettingVariant::Cpu, }) .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 || (self.state.is_resuming && !self.limits.skip_resume_reclock) || POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.needs_manual() @@ -339,17 +331,6 @@ impl Cpu { setting: crate::settings::SettingVariant::Cpu, }) .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 @@ -358,12 +339,16 @@ impl Cpu { } // commit changes (if no errors have already occured) if errors.is_empty() { - usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n").map_err(|e| { - vec![SettingError { - msg: format!("Failed to write `c` to `{}`: {}", CPU_CLOCK_LIMITS_PATH, e), - setting: crate::settings::SettingVariant::Cpu, - }] - }) + if POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.needs_manual() { + usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n").map_err(|e| { + vec![SettingError { + msg: format!("Failed to write `c` to `{}`: {}", CPU_CLOCK_LIMITS_PATH, e), + setting: crate::settings::SettingVariant::Cpu, + }] + }) + } else { + Ok(()) + } } else { Err(errors) }