-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: don't duplicate AMD GPU temperature retrieval (#1682)
* some file/struct renaming * refactor: don't get AMD gpu temperatures twice
- Loading branch information
1 parent
f7d070f
commit d2177ed
Showing
7 changed files
with
136 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::{fs, path::Path}; | ||
|
||
/// Whether the temperature should *actually* be read during enumeration. | ||
/// Will return false if the state is not D0/unknown, or if it does not support | ||
/// `device/power_state`. | ||
/// | ||
/// `path` is a path to the device itself (e.g. `/sys/class/hwmon/hwmon1/device`). | ||
#[inline] | ||
pub fn is_device_awake(device: &Path) -> bool { | ||
// Whether the temperature should *actually* be read during enumeration. | ||
// Set to false if the device is in ACPI D3cold. | ||
// Documented at https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-power_state | ||
let power_state = device.join("power_state"); | ||
if power_state.exists() { | ||
if let Ok(state) = fs::read_to_string(power_state) { | ||
let state = state.trim(); | ||
// The zenpower3 kernel module (incorrectly?) reports "unknown", causing this | ||
// check to fail and temperatures to appear as zero instead of | ||
// having the file not exist. | ||
// | ||
// Their self-hosted git instance has disabled sign up, so this bug cant be | ||
// reported either. | ||
state == "D0" || state == "unknown" | ||
} else { | ||
true | ||
} | ||
} else { | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.