From b52441f1adf2a212c8ddf7693c8271f8649ea519 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Thu, 23 Feb 2023 21:43:00 -0500 Subject: [PATCH] Add const to set hwmon index --- backend-rs/src/sys.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend-rs/src/sys.rs b/backend-rs/src/sys.rs index 9bc0cd7..298284b 100644 --- a/backend-rs/src/sys.rs +++ b/backend-rs/src/sys.rs @@ -1,7 +1,9 @@ use usdpl_back::api::files::*; +const HWMON_INDEX: usize = 5; + pub fn read_fan() -> Option { - 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 { @@ -9,9 +11,9 @@ pub fn read_thermal_zone(index: u8) -> Option { } 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> { - write_single("/sys/class/hwmon/hwmon5/fan1_target", rpm) + write_single(format!("/sys/class/hwmon/hwmon{}/fan1_target", HWMON_INDEX), rpm) }