Fix the handling of of the kernel change from "quiet" to "low-power"

A coming kernel change will convert "quiet" to "low-power" due to how
platform_profile can now have multiple registered handlers.
(kernel 6.14 est)

Fixes #609
This commit is contained in:
Luke Jones
2025-02-14 19:38:02 +13:00
parent 2c006699f2
commit 4dd29952c8
13 changed files with 146 additions and 71 deletions

View File

@@ -15,6 +15,7 @@ use std::path::Path;
use error::{PlatformError, Result};
use log::warn;
use platform::PlatformProfile;
use udev::Device;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -107,6 +108,18 @@ pub fn write_attr_string(device: &mut Device, attr: &str, value: &str) -> Result
.map_err(|e| PlatformError::IoPath(attr.into(), e))
}
pub fn read_attr_string_array(device: &Device, attr_name: &str) -> Result<Vec<PlatformProfile>> {
if let Some(value) = device.attribute_value(attr_name) {
let tmp: Vec<PlatformProfile> = value
.to_string_lossy()
.split(' ')
.map(PlatformProfile::from)
.collect();
return Ok(tmp);
}
Err(PlatformError::AttrNotFound(attr_name.to_owned()))
}
#[cfg(test)]
mod tests {
#[test]