Skip to content

Commit

Permalink
Merge pull request #445 from JakeRoggenbuck/fix-amd-thermal
Browse files Browse the repository at this point in the history
Add fix for amd thermal
  • Loading branch information
JakeRoggenbuck authored Oct 30, 2022
2 parents bcc8b94 + f193a6f commit e6e9de3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,20 @@ pub enum WritableValue {
impl Speed for CPU {
/// Read the temperature of a cpu
fn read_temp(&mut self, sub_path: &str) -> Result<i32, Error> {
let cpu_info_path: String = format!(
let mut cpu_info_path: String = format!(
"/sys/class/thermal/{}/{}",
self.name.replace("cpu", "thermal_zone"),
sub_path
);

// If the thermal path does not exist, use the first thermal path only if it exists
if !Path::new(&cpu_info_path).exists() {
return Ok(-1);
let first_core_path = format!("/sys/class/thermal/thermal_zone0/{}", sub_path);
if Path::new(&first_core_path).exists() {
cpu_info_path = first_core_path;
} else {
return Ok(-1);
}
}

let mut info = fs::read_to_string(cpu_info_path)?;
Expand Down

0 comments on commit e6e9de3

Please sign in to comment.