mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fix clippy warnings
This commit is contained in:
@@ -90,7 +90,7 @@ impl AuraConfig {
|
|||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
if let Ok(read_len) = file.read_to_string(&mut buf) {
|
if let Ok(read_len) = file.read_to_string(&mut buf) {
|
||||||
if read_len == 0 {
|
if read_len == 0 {
|
||||||
return AuraConfig::create_default(&mut file, &supported_led_modes);
|
return AuraConfig::create_default(&mut file, supported_led_modes);
|
||||||
} else {
|
} else {
|
||||||
if let Ok(data) = serde_json::from_str(&buf) {
|
if let Ok(data) = serde_json::from_str(&buf) {
|
||||||
return data;
|
return data;
|
||||||
@@ -109,7 +109,7 @@ impl AuraConfig {
|
|||||||
panic!("Please remove {} then restart asusd", AURA_CONFIG_PATH);
|
panic!("Please remove {} then restart asusd", AURA_CONFIG_PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AuraConfig::create_default(&mut file, &supported_led_modes)
|
AuraConfig::create_default(&mut file, supported_led_modes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_default(file: &mut File, support_data: &LaptopLedData) -> Self {
|
fn create_default(file: &mut File, support_data: &LaptopLedData) -> Self {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use logind_zbus::{
|
|||||||
ManagerProxy, SessionProxy,
|
ManagerProxy, SessionProxy,
|
||||||
};
|
};
|
||||||
use rog_types::gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors};
|
use rog_types::gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors};
|
||||||
use std::iter::FromIterator;
|
|
||||||
use std::{io::Write, ops::Add, path::Path, time::Instant};
|
use std::{io::Write, ops::Add, path::Path, time::Instant};
|
||||||
use std::{process::Command, thread::sleep, time::Duration};
|
use std::{process::Command, thread::sleep, time::Duration};
|
||||||
use std::{str::FromStr, sync::mpsc};
|
use std::{str::FromStr, sync::mpsc};
|
||||||
@@ -79,20 +78,20 @@ impl CtrlGraphics {
|
|||||||
match dev.vendor()? {
|
match dev.vendor()? {
|
||||||
0x1002 => {
|
0x1002 => {
|
||||||
info!("GFX: {}: AMD graphics", dev.id());
|
info!("GFX: {}: AMD graphics", dev.id());
|
||||||
amd.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev)));
|
amd.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
|
||||||
}
|
}
|
||||||
0x10DE => {
|
0x10DE => {
|
||||||
info!("GFX: {}: NVIDIA graphics", dev.id());
|
info!("GFX: {}: NVIDIA graphics", dev.id());
|
||||||
dev.set_runtime_pm(sysfs_class::RuntimePowerManagement::On)?;
|
dev.set_runtime_pm(sysfs_class::RuntimePowerManagement::On)?;
|
||||||
nvidia.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev)));
|
nvidia.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
|
||||||
}
|
}
|
||||||
0x8086 => {
|
0x8086 => {
|
||||||
info!("GFX: {}: Intel graphics", dev.id());
|
info!("GFX: {}: Intel graphics", dev.id());
|
||||||
intel.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev)));
|
intel.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
|
||||||
}
|
}
|
||||||
vendor => {
|
vendor => {
|
||||||
info!("GFX: {}: Other({:X}) graphics", dev.id(), vendor);
|
info!("GFX: {}: Other({:X}) graphics", dev.id(), vendor);
|
||||||
other.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev)));
|
other.push(GraphicsDevice::new(dev.id().to_owned(), functions(dev)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,13 +264,13 @@ impl CtrlGraphics {
|
|||||||
let unbinds = devices.iter().map(|dev| dev.unbind());
|
let unbinds = devices.iter().map(|dev| dev.unbind());
|
||||||
// Remove NVIDIA graphics devices and their functions
|
// Remove NVIDIA graphics devices and their functions
|
||||||
let removes = devices.iter().map(|dev| dev.remove());
|
let removes = devices.iter().map(|dev| dev.remove());
|
||||||
Result::from_iter(unbinds.chain(removes))
|
unbinds.chain(removes).collect::<Result<_, _>>()
|
||||||
.map_err(|err| RogError::Command("device unbind error".into(), err))
|
.map_err(|err| RogError::Command("device unbind error".into(), err))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_only(devices: &[GraphicsDevice]) -> Result<(), RogError> {
|
fn unbind_only(devices: &[GraphicsDevice]) -> Result<(), RogError> {
|
||||||
let unbinds = devices.iter().map(|dev| dev.unbind());
|
let unbinds = devices.iter().map(|dev| dev.unbind());
|
||||||
Result::from_iter(unbinds)
|
unbinds.collect::<Result<_, _>>()
|
||||||
.map_err(|err| RogError::Command("device unbind error".into(), err))
|
.map_err(|err| RogError::Command("device unbind error".into(), err))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,7 +461,7 @@ impl CtrlGraphics {
|
|||||||
for driver in NVIDIA_DRIVERS.iter() {
|
for driver in NVIDIA_DRIVERS.iter() {
|
||||||
Self::do_driver_action(driver, "rmmod")?;
|
Self::do_driver_action(driver, "rmmod")?;
|
||||||
}
|
}
|
||||||
Self::unbind_only(&devices)?;
|
Self::unbind_only(devices)?;
|
||||||
Self::do_driver_action("vfio-pci", "modprobe")?;
|
Self::do_driver_action("vfio-pci", "modprobe")?;
|
||||||
} else {
|
} else {
|
||||||
return Err(GfxError::VfioDisabled.into());
|
return Err(GfxError::VfioDisabled.into());
|
||||||
@@ -478,7 +477,7 @@ impl CtrlGraphics {
|
|||||||
for driver in NVIDIA_DRIVERS.iter() {
|
for driver in NVIDIA_DRIVERS.iter() {
|
||||||
Self::do_driver_action(driver, "rmmod")?;
|
Self::do_driver_action(driver, "rmmod")?;
|
||||||
}
|
}
|
||||||
Self::unbind_remove_nvidia(&devices)?;
|
Self::unbind_remove_nvidia(devices)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ impl GraphicsDevice {
|
|||||||
Ok(driver) => {
|
Ok(driver) => {
|
||||||
info!("{}: Unbinding {}", driver.id(), func.id());
|
info!("{}: Unbinding {}", driver.id(), func.id());
|
||||||
unsafe {
|
unsafe {
|
||||||
driver.unbind(&func).map_err(|err| {
|
driver.unbind(func).map_err(|err| {
|
||||||
error!("gfx unbind: {}", err);
|
error!("gfx unbind: {}", err);
|
||||||
err
|
err
|
||||||
})?;
|
})?;
|
||||||
@@ -109,7 +109,7 @@ impl GraphicsDevice {
|
|||||||
Ok(driver) => {
|
Ok(driver) => {
|
||||||
info!("{}: Binding {}", driver.id(), func.id());
|
info!("{}: Binding {}", driver.id(), func.id());
|
||||||
unsafe {
|
unsafe {
|
||||||
driver.bind(&func).map_err(|err| {
|
driver.bind(func).map_err(|err| {
|
||||||
error!("gfx bind: {}", err);
|
error!("gfx bind: {}", err);
|
||||||
err
|
err
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ impl CtrlKbdLed {
|
|||||||
|
|
||||||
self.config.read();
|
self.config.read();
|
||||||
if let Some(data) = self.config.builtins.get(&next) {
|
if let Some(data) = self.config.builtins.get(&next) {
|
||||||
self.write_mode(&data)?;
|
self.write_mode(data)?;
|
||||||
self.config.current_mode = next;
|
self.config.current_mode = next;
|
||||||
}
|
}
|
||||||
self.config.write();
|
self.config.write();
|
||||||
@@ -381,7 +381,7 @@ impl CtrlKbdLed {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_mode(&self, mode: &AuraEffect) -> Result<(), RogError> {
|
fn write_mode(&self, mode: &AuraEffect) -> Result<(), RogError> {
|
||||||
if !self.supported_modes.standard.contains(&mode.mode()) {
|
if !self.supported_modes.standard.contains(mode.mode()) {
|
||||||
return Err(RogError::NotSupported);
|
return Err(RogError::NotSupported);
|
||||||
}
|
}
|
||||||
let bytes: [u8; LED_MSG_LEN] = mode.into();
|
let bytes: [u8; LED_MSG_LEN] = mode.into();
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ impl FanAndCpuZbus {
|
|||||||
if let Ok(ctrl) = self.inner.try_lock() {
|
if let Ok(ctrl) = self.inner.try_lock() {
|
||||||
if let Ok(cfg) = ctrl.config.clone().try_lock() {
|
if let Ok(cfg) = ctrl.config.clone().try_lock() {
|
||||||
if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) {
|
if let Some(profile) = cfg.power_profiles.get(&cfg.active_profile) {
|
||||||
self.notify_profile(&profile)
|
self.notify_profile(profile)
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ impl Sequences {
|
|||||||
|
|
||||||
pub fn iter(&self) -> ActionIterator {
|
pub fn iter(&self) -> ActionIterator {
|
||||||
ActionIterator {
|
ActionIterator {
|
||||||
actions: &self,
|
actions: self,
|
||||||
next_idx: 0,
|
next_idx: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user