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

@@ -38,7 +38,7 @@ pub enum AttrValue {
EnumInt(Vec<i32>),
EnumStr(Vec<String>),
#[default]
None
None,
}
#[derive(Debug, Default, Clone)]
@@ -50,7 +50,7 @@ pub struct Attribute {
min_value: AttrValue,
max_value: AttrValue,
scalar_increment: AttrValue,
base_path: PathBuf
base_path: PathBuf,
}
impl Attribute {
@@ -72,7 +72,7 @@ impl Attribute {
Ok(AttrValue::String(val))
}
}
Err(e) => Err(e)
Err(e) => Err(e),
}
}
@@ -92,7 +92,7 @@ impl Attribute {
let value_str = match new_value {
AttrValue::Integer(val) => &val.to_string(),
AttrValue::String(val) => val,
_ => return Err(PlatformError::InvalidValue)
_ => return Err(PlatformError::InvalidValue),
};
let mut file = OpenOptions::new().write(true).open(&path)?;
@@ -128,7 +128,7 @@ impl Attribute {
/// change, if they do then it is possibly a driver issue - although this is
/// subject to `firmware_attributes` class changes in kernel.
fn read_base_values(
base_path: &Path
base_path: &Path,
) -> (AttrValue, AttrValue, AttrValue, AttrValue, AttrValue) {
let default_value = match read_string(&base_path.join("default_value")) {
Ok(val) => {
@@ -138,7 +138,7 @@ impl Attribute {
AttrValue::String(val)
}
}
Err(_) => AttrValue::None
Err(_) => AttrValue::None,
};
let possible_values = match read_string(&base_path.join("possible_values")) {
@@ -151,7 +151,7 @@ impl Attribute {
AttrValue::EnumStr(val.split(';').map(|s| s.to_string()).collect())
}
}
Err(_) => AttrValue::None
Err(_) => AttrValue::None,
};
let min_value = read_i32(&base_path.join("min_value"))
@@ -168,7 +168,7 @@ impl Attribute {
.unwrap_or_default();
(
default_value, possible_values, min_value, max_value, scalar_increment
default_value, possible_values, min_value, max_value, scalar_increment,
)
}
@@ -194,7 +194,7 @@ impl Attribute {
#[derive(Clone)]
pub struct FirmwareAttributes {
attrs: Vec<Attribute>
attrs: Vec<Attribute>,
}
#[allow(clippy::new_without_default)]
@@ -221,7 +221,7 @@ impl FirmwareAttributes {
min_value,
max_value,
scalar_increment,
base_path
base_path,
});
}
}
@@ -305,7 +305,7 @@ pub enum FirmwareAttribute {
MiniLedMode = 22,
PendingReboot = 23,
PptEnabled = 24,
None = 25
None = 25,
}
impl FirmwareAttribute {
@@ -395,7 +395,7 @@ impl From<FirmwareAttribute> for &str {
FirmwareAttribute::GpuMuxMode => "gpu_mux_mode",
FirmwareAttribute::MiniLedMode => "mini_led_mode",
FirmwareAttribute::PendingReboot => "pending_reboot",
FirmwareAttribute::None => "none"
FirmwareAttribute::None => "none",
}
}
}

View File

@@ -18,7 +18,7 @@ const ATTR_EPP: &str = "cpufreq/energy_performance_preference";
/// which can drastically alter CPU performance.
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
pub struct CPUControl {
paths: Vec<PathBuf>
paths: Vec<PathBuf>,
}
impl CPUControl {
@@ -54,7 +54,7 @@ impl CPUControl {
}
match device.attribute_value(ATTR_GOVERNOR) {
Some(g) => info!("{ATTR_GOVERNOR}: {g:?}"),
None => return Err(PlatformError::CPU(format!("{ATTR_GOVERNOR} not found")))
None => return Err(PlatformError::CPU(format!("{ATTR_GOVERNOR} not found"))),
}
match device.attribute_value(ATTR_AVAILABLE_EPP) {
Some(g) => info!("{ATTR_AVAILABLE_EPP}: {g:?}"),
@@ -66,7 +66,7 @@ impl CPUControl {
}
match device.attribute_value(ATTR_EPP) {
Some(g) => info!("{ATTR_EPP}: {g:?}"),
None => return Err(PlatformError::CPU(format!("{ATTR_EPP} not found")))
None => return Err(PlatformError::CPU(format!("{ATTR_EPP} not found"))),
}
supported = true;
}
@@ -77,7 +77,7 @@ impl CPUControl {
}
if cpu.paths.is_empty() {
return Err(PlatformError::MissingFunction(
"asus-nb-wmi not found".into()
"asus-nb-wmi not found".into(),
));
}
Ok(cpu)
@@ -154,7 +154,7 @@ impl CPUControl {
pub enum CPUGovernor {
Performance = 0,
Powersave = 1,
BadValue = 2
BadValue = 2,
}
impl From<&str> for CPUGovernor {
@@ -162,7 +162,7 @@ impl From<&str> for CPUGovernor {
match s {
"performance" => Self::Performance,
"powersave" => Self::Powersave,
_ => Self::BadValue
_ => Self::BadValue,
}
}
}
@@ -172,7 +172,7 @@ impl From<CPUGovernor> for String {
match g {
CPUGovernor::Performance => "performance".to_string(),
CPUGovernor::Powersave => "powersave".to_string(),
CPUGovernor::BadValue => "bad_value".to_string()
CPUGovernor::BadValue => "bad_value".to_string(),
}
}
}
@@ -198,7 +198,7 @@ pub enum CPUEPP {
Performance = 1,
BalancePerformance = 2,
BalancePower = 3,
Power = 4
Power = 4,
}
impl From<PlatformProfile> for CPUEPP {
@@ -206,7 +206,7 @@ impl From<PlatformProfile> for CPUEPP {
match value {
PlatformProfile::Balanced => CPUEPP::BalancePerformance,
PlatformProfile::Performance => CPUEPP::Performance,
PlatformProfile::Quiet => CPUEPP::Power
PlatformProfile::Quiet => CPUEPP::Power,
}
}
}
@@ -219,7 +219,7 @@ impl From<&str> for CPUEPP {
"balance_performance" => Self::BalancePerformance,
"balance_power" => Self::BalancePower,
"power" => Self::Power,
_ => Self::Default
_ => Self::Default,
}
}
}
@@ -231,7 +231,7 @@ impl From<CPUEPP> for String {
CPUEPP::Performance => "performance".to_string(),
CPUEPP::BalancePerformance => "balance_performance".to_string(),
CPUEPP::BalancePower => "balance_power".to_string(),
CPUEPP::Power => "power".to_string()
CPUEPP::Power => "power".to_string(),
}
}
}
@@ -244,7 +244,7 @@ impl From<i32> for CPUEPP {
2 => Self::BalancePerformance,
3 => Self::BalancePower,
4 => Self::Power,
_ => Self::Default
_ => Self::Default,
}
}
}

View File

@@ -22,7 +22,7 @@ pub enum PlatformError {
InvalidValue,
NoAuraKeyboard,
NoAuraNode,
CPU(String)
CPU(String),
}
impl fmt::Display for PlatformError {
@@ -52,7 +52,7 @@ impl fmt::Display for PlatformError {
PlatformError::IoPath(path, detail) => write!(f, "{} {}", path, detail),
PlatformError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"),
PlatformError::NoAuraNode => write!(f, "No Aura keyboard node found"),
PlatformError::CPU(s) => write!(f, "CPU control: {s}")
PlatformError::CPU(s) => write!(f, "CPU control: {s}"),
}
}
}
@@ -76,7 +76,7 @@ impl From<PlatformError> for FdoErr {
log::error!("PlatformError: got: {error}");
match error {
PlatformError::NotSupported => FdoErr::NotSupported("".to_owned()),
_ => FdoErr::Failed(format!("Failed with {error}"))
_ => FdoErr::Failed(format!("Failed with {error}")),
}
}
}

View File

@@ -19,7 +19,7 @@ pub struct HidRaw {
prod_id: String,
_device_bcd: u32,
/// Retaining a handle to the file for the duration of `HidRaw`
file: RefCell<File>
file: RefCell<File>,
}
impl HidRaw {
@@ -66,7 +66,7 @@ impl HidRaw {
.unwrap_or_default()
.to_string_lossy()
.parse()
.unwrap_or_default()
.unwrap_or_default(),
});
}
}
@@ -98,13 +98,13 @@ impl HidRaw {
.unwrap_or_default()
.to_string_lossy()
.parse()
.unwrap_or_default()
.unwrap_or_default(),
});
}
}
}
Err(PlatformError::MissingFunction(
"hidraw dev no dev path".to_string()
"hidraw dev no dev path".to_string(),
))
}

View File

@@ -10,7 +10,7 @@ use crate::{attr_u8, has_attr, set_attr_u8_array, to_device};
/// for Aura keyboards
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Clone)]
pub struct KeyboardBacklight {
path: PathBuf
path: PathBuf,
}
impl KeyboardBacklight {
@@ -51,12 +51,12 @@ impl KeyboardBacklight {
if sys.contains("kbd_backlight") || sys.contains("ally:rgb:gamepad") {
info!("Found keyboard LED controls at {:?}", device.sysname());
return Ok(Self {
path: device.syspath().to_owned()
path: device.syspath().to_owned(),
});
}
}
Err(PlatformError::MissingFunction(
"KeyboardLed:new(), asus::kbd_backlight not found".into()
"KeyboardLed:new(), asus::kbd_backlight not found".into(),
))
}
}

View File

@@ -112,7 +112,7 @@ mod tests {
#[test]
fn check() {
let data = [
1, 2, 3, 4, 5
1, 2, 3, 4, 5,
];
let mut tmp = String::new();
for n in data {

View File

@@ -20,7 +20,7 @@ use crate::{attr_string, to_device};
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
pub struct RogPlatform {
path: PathBuf,
pp_path: PathBuf
pp_path: PathBuf,
}
impl RogPlatform {
@@ -53,11 +53,11 @@ impl RogPlatform {
info!("Found platform support at {:?}", device.sysname());
return Ok(Self {
path: device.syspath().to_owned(),
pp_path: PathBuf::from_str("/sys/firmware/acpi").unwrap()
pp_path: PathBuf::from_str("/sys/firmware/acpi").unwrap(),
});
}
Err(PlatformError::MissingFunction(
"asus-nb-wmi not found".into()
"asus-nb-wmi not found".into(),
))
}
}
@@ -67,7 +67,7 @@ impl Default for RogPlatform {
unsafe {
Self {
path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked(),
pp_path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked()
pp_path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked(),
}
}
}
@@ -85,7 +85,7 @@ pub enum GpuMode {
Ultimate = 4,
#[default]
Error = 254,
NotSupported = 255
NotSupported = 255,
}
impl From<u8> for GpuMode {
@@ -97,7 +97,7 @@ impl From<u8> for GpuMode {
3 => GpuMode::Vfio,
4 => GpuMode::Ultimate,
5 => GpuMode::Error,
_ => GpuMode::NotSupported
_ => GpuMode::NotSupported,
}
}
}
@@ -164,7 +164,7 @@ impl Display for GpuMode {
GpuMode::Vfio => write!(f, "VFIO"),
GpuMode::Ultimate => write!(f, "Ultimate"),
GpuMode::Error => write!(f, "Error"),
GpuMode::NotSupported => write!(f, "Not Supported")
GpuMode::NotSupported => write!(f, "Not Supported"),
}
}
}
@@ -191,7 +191,7 @@ pub enum PlatformProfile {
#[default]
Balanced = 0,
Performance = 1,
Quiet = 2
Quiet = 2,
}
impl PlatformProfile {
@@ -199,7 +199,7 @@ impl PlatformProfile {
match self {
Self::Balanced => Self::Performance,
Self::Performance => Self::Quiet,
Self::Quiet => Self::Balanced
Self::Quiet => Self::Balanced,
}
}
@@ -207,7 +207,7 @@ impl PlatformProfile {
[
Self::Balanced,
Self::Performance,
Self::Quiet
Self::Quiet,
]
}
}
@@ -237,7 +237,7 @@ impl From<PlatformProfile> for u8 {
match p {
PlatformProfile::Balanced => 0,
PlatformProfile::Performance => 1,
PlatformProfile::Quiet => 2
PlatformProfile::Quiet => 2,
}
}
}
@@ -253,7 +253,7 @@ impl From<PlatformProfile> for &str {
match profile {
PlatformProfile::Balanced => "balanced",
PlatformProfile::Performance => "performance",
PlatformProfile::Quiet => "quiet"
PlatformProfile::Quiet => "quiet",
}
}
}
@@ -288,7 +288,7 @@ impl std::str::FromStr for PlatformProfile {
"performance" => Ok(PlatformProfile::Performance),
"quiet" => Ok(PlatformProfile::Quiet),
"low-power" => Ok(PlatformProfile::Quiet),
_ => Err(PlatformError::NotSupported)
_ => Err(PlatformError::NotSupported),
}
}
}
@@ -311,5 +311,5 @@ pub enum Properties {
PanelOd,
MiniLedMode,
EgpuEnable,
ThrottlePolicy
ThrottlePolicy,
}

View File

@@ -16,7 +16,7 @@ use crate::{attr_u8, to_device};
pub struct AsusPower {
mains: PathBuf,
battery: PathBuf,
usb: Option<PathBuf>
usb: Option<PathBuf>,
}
impl AsusPower {
@@ -97,12 +97,12 @@ impl AsusPower {
return Ok(Self {
mains,
battery,
usb
usb,
});
}
Err(PlatformError::MissingFunction(
"Did not find a battery".to_owned()
"Did not find a battery".to_owned(),
))
}
}

View File

@@ -24,7 +24,7 @@ impl USBRaw {
}
fn get_dev_handle(
device: &Device<rusb::GlobalContext>
device: &Device<rusb::GlobalContext>,
) -> Result<DeviceHandle<rusb::GlobalContext>> {
// We don't expect this ID to ever change
let device = device.open()?;
@@ -42,7 +42,7 @@ impl USBRaw {
0x35e, // value
0x00, // index
message,
Duration::from_millis(200)
Duration::from_millis(200),
)
.map_err(PlatformError::USB)
}