Reformat with trailing comma

This commit is contained in:
Luke Jones
2025-02-14 16:06:20 +13:00
parent 0bdf0474c9
commit 2c006699f2
113 changed files with 791 additions and 792 deletions

View File

@@ -16,7 +16,7 @@ pub enum ProfileError {
/// (pwm/temp, prev, next)
ParseFanCurvePrevHigher(&'static str, u8, u8),
ParseFanCurvePercentOver100(u8),
NotEnoughPoints // Zbus(zbus::Error),
NotEnoughPoints, // Zbus(zbus::Error),
}
impl fmt::Display for ProfileError {
@@ -60,7 +60,7 @@ impl From<ProfileError> for FdoErr {
error!("ProfileError: got: {error}");
match error {
ProfileError::NotSupported => FdoErr::NotSupported("".to_owned()),
_ => FdoErr::Failed(format!("Failed with {error}"))
_ => FdoErr::Failed(format!("Failed with {error}")),
}
}
}

View File

@@ -36,7 +36,7 @@ pub struct CurveData {
pub fan: FanCurvePU,
pub pwm: [u8; 8],
pub temp: [u8; 8],
pub enabled: bool
pub enabled: bool,
}
impl From<&CurveData> for String {
@@ -99,7 +99,7 @@ impl std::str::FromStr for CurveData {
if select == 0 {
if temp_prev > r {
return Err(ProfileError::ParseFanCurvePrevHigher(
"temperature", temp_prev, r
"temperature", temp_prev, r,
));
}
temp_prev = r;
@@ -114,7 +114,7 @@ impl std::str::FromStr for CurveData {
}
if pwm_prev > p {
return Err(ProfileError::ParseFanCurvePrevHigher(
"percentage", pwm_prev, p
"percentage", pwm_prev, p,
));
}
pwm_prev = p;
@@ -126,7 +126,7 @@ impl std::str::FromStr for CurveData {
fan: FanCurvePU::CPU,
pwm,
temp,
enabled: false
enabled: false,
})
}
}

View File

@@ -41,7 +41,7 @@ pub fn find_fan_curve_node() -> Result<Device, ProfileError> {
pub enum FanCurvePU {
CPU = 0,
GPU = 1,
MID = 2
MID = 2,
}
impl FanCurvePU {
@@ -50,7 +50,7 @@ impl FanCurvePU {
for fan in [
Self::CPU,
Self::GPU,
Self::MID
Self::MID,
] {
let pwm_num: char = fan.into();
let pwm_enable = format!("pwm{pwm_num}_enable");
@@ -72,7 +72,7 @@ impl From<FanCurvePU> for &str {
match pu {
FanCurvePU::CPU => "cpu",
FanCurvePU::GPU => "gpu",
FanCurvePU::MID => "mid"
FanCurvePU::MID => "mid",
}
}
}
@@ -82,7 +82,7 @@ impl From<FanCurvePU> for char {
match pu {
FanCurvePU::CPU => '1',
FanCurvePU::GPU => '2',
FanCurvePU::MID => '3'
FanCurvePU::MID => '3',
}
}
}
@@ -95,7 +95,7 @@ impl std::str::FromStr for FanCurvePU {
"cpu" => Ok(FanCurvePU::CPU),
"gpu" => Ok(FanCurvePU::GPU),
"mid" => Ok(FanCurvePU::MID),
_ => Err(ProfileError::ParseProfileName)
_ => Err(ProfileError::ParseProfileName),
}
}
}
@@ -112,7 +112,7 @@ impl Default for FanCurvePU {
pub struct FanCurveProfiles {
pub balanced: Vec<CurveData>,
pub performance: Vec<CurveData>,
pub quiet: Vec<CurveData>
pub quiet: Vec<CurveData>,
}
impl FanCurveProfiles {
@@ -126,7 +126,7 @@ impl FanCurveProfiles {
pub fn read_from_dev_profile(
&mut self,
profile: PlatformProfile,
device: &Device
device: &Device,
) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?;
let mut curves = Vec::with_capacity(3);
@@ -145,7 +145,7 @@ impl FanCurveProfiles {
match profile {
PlatformProfile::Balanced => self.balanced = curves,
PlatformProfile::Performance => self.performance = curves,
PlatformProfile::Quiet => self.quiet = curves
PlatformProfile::Quiet => self.quiet = curves,
}
Ok(())
}
@@ -158,7 +158,7 @@ impl FanCurveProfiles {
pub fn set_active_curve_to_defaults(
&mut self,
profile: PlatformProfile,
device: &mut Device
device: &mut Device,
) -> Result<(), ProfileError> {
let fans = Self::supported_fans()?;
// Do reset for all
@@ -176,12 +176,12 @@ impl FanCurveProfiles {
pub fn write_profile_curve_to_platform(
&mut self,
profile: PlatformProfile,
device: &mut Device
device: &mut Device,
) -> Result<(), ProfileError> {
let fans = match profile {
PlatformProfile::Balanced => &mut self.balanced,
PlatformProfile::Performance => &mut self.performance,
PlatformProfile::Quiet => &mut self.quiet
PlatformProfile::Quiet => &mut self.quiet,
};
for fan in fans.iter().filter(|f| !f.enabled) {
debug!("write_profile_curve_to_platform: writing profile:{profile}, {fan:?}");
@@ -220,7 +220,7 @@ impl FanCurveProfiles {
&mut self,
profile: PlatformProfile,
fan: FanCurvePU,
enabled: bool
enabled: bool,
) {
match profile {
PlatformProfile::Balanced => {
@@ -254,7 +254,7 @@ impl FanCurveProfiles {
match name {
PlatformProfile::Balanced => &self.balanced,
PlatformProfile::Performance => &self.performance,
PlatformProfile::Quiet => &self.quiet
PlatformProfile::Quiet => &self.quiet,
}
}
@@ -288,7 +288,7 @@ impl FanCurveProfiles {
pub fn save_fan_curve(
&mut self,
curve: CurveData,
profile: PlatformProfile
profile: PlatformProfile,
) -> Result<(), ProfileError> {
match profile {
PlatformProfile::Balanced => {