Add const to set hwmon index
This commit is contained in:
parent
95dab80171
commit
b52441f1ad
1 changed files with 5 additions and 3 deletions
|
@ -1,7 +1,9 @@
|
||||||
use usdpl_back::api::files::*;
|
use usdpl_back::api::files::*;
|
||||||
|
|
||||||
|
const HWMON_INDEX: usize = 5;
|
||||||
|
|
||||||
pub fn read_fan() -> Option<u64> {
|
pub fn read_fan() -> Option<u64> {
|
||||||
read_single("/sys/class/hwmon/hwmon5/fan1_input").ok()
|
read_single(format!("/sys/class/hwmon/hwmon{}/fan1_input", HWMON_INDEX)).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_thermal_zone(index: u8) -> Option<u64> {
|
pub fn read_thermal_zone(index: u8) -> Option<u64> {
|
||||||
|
@ -9,9 +11,9 @@ pub fn read_thermal_zone(index: u8) -> Option<u64> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_fan_recalc(enabled: bool) -> Result<(), std::io::Error> {
|
pub fn write_fan_recalc(enabled: bool) -> Result<(), std::io::Error> {
|
||||||
write_single("/sys/class/hwmon/hwmon5/recalculate", enabled as u8)
|
write_single(format!("/sys/class/hwmon/hwmon{}/recalculate", HWMON_INDEX), enabled as u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_fan_target(rpm: u64) -> Result<(), std::io::Error> {
|
pub fn write_fan_target(rpm: u64) -> Result<(), std::io::Error> {
|
||||||
write_single("/sys/class/hwmon/hwmon5/fan1_target", rpm)
|
write_single(format!("/sys/class/hwmon/hwmon{}/fan1_target", HWMON_INDEX), rpm)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue