mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
cpu: streamline governor setting; consolidate sharaed logic
This commit is contained in:
parent
58ba603afc
commit
00805d2808
5 changed files with 108 additions and 127 deletions
|
@ -408,14 +408,15 @@ pub fn get_cpu_global_info(cpu_cores: &[CpuCoreInfo]) -> CpuGlobalInfo {
|
|||
let mut cpufreq_base_path_buf = PathBuf::from("/sys/devices/system/cpu/cpu0/cpufreq/");
|
||||
|
||||
if !cpufreq_base_path_buf.exists() {
|
||||
// Fallback: find first available CPU with cpufreq
|
||||
for i in 1..=get_logical_core_count().unwrap_or(1) {
|
||||
let test_path = format!("/sys/devices/system/cpu/cpu{}/cpufreq/", i - 1);
|
||||
let test_path_buf = PathBuf::from(&test_path);
|
||||
if test_path_buf.exists() {
|
||||
cpufreq_base_path_buf = test_path_buf;
|
||||
break;
|
||||
}
|
||||
let core_count = get_logical_core_count().unwrap_or_else(|e| {
|
||||
eprintln!("Warning: {e}");
|
||||
0
|
||||
});
|
||||
let path = (0..core_count)
|
||||
.map(|i| PathBuf::from(format!("/sys/devices/system/cpu/cpu{i}/cpufreq/")))
|
||||
.find(|path| path.exists());
|
||||
if let Some(test_path_buf) = path {
|
||||
cpufreq_base_path_buf = test_path_buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue