power: Expose TDP limit range as platform config

This commit is contained in:
Vicki Pfau 2024-08-27 21:57:50 -07:00
parent 36e88484a4
commit 7c3f2baa05
5 changed files with 46 additions and 7 deletions

View file

@ -26,8 +26,17 @@ pub(crate) struct PlatformConfig {
pub update_dock: Option<ScriptConfig>,
pub storage: Option<StorageConfig>,
pub fan_control: Option<ServiceConfig>,
pub tdp_limit: Option<RangeConfig<u32>>,
}
#[derive(Clone, Deserialize, Debug)]
pub(crate) struct RangeConfig<T: Clone> {
pub min: T,
pub max: T,
}
impl<T> Copy for RangeConfig<T> where T: Copy {}
#[derive(Clone, Default, Deserialize, Debug)]
pub(crate) struct ScriptConfig {
pub script: PathBuf,
@ -67,6 +76,13 @@ pub(crate) struct FormatDeviceConfig {
pub no_validate_flag: Option<String>,
}
impl<T: Clone> RangeConfig<T> {
#[allow(unused)]
pub(crate) fn new(min: T, max: T) -> RangeConfig<T> {
RangeConfig { min, max }
}
}
impl PlatformConfig {
#[cfg(not(test))]
async fn load() -> Result<Option<PlatformConfig>> {