diff --git a/device-api/src/arch/mod.rs b/device-api/src/arch/mod.rs index b6cf4c0..75678ad 100644 --- a/device-api/src/arch/mod.rs +++ b/device-api/src/arch/mod.rs @@ -38,10 +38,12 @@ impl Arch { sysfs: &str, ) -> DeviceResult> { match self { - Arch::WarboyB0 => WarboyInner::new(*self, idx, sysfs.into()) - .map(|t| Box::new(t) as Box), - Arch::Renegade => RenegadeInner::new(*self, idx, sysfs.into()) - .map(|t| Box::new(t) as Box), + Arch::WarboyB0 => { + WarboyInner::new(idx, sysfs.into()).map(|t| Box::new(t) as Box) + } + Arch::Renegade => { + RenegadeInner::new(idx, sysfs.into()).map(|t| Box::new(t) as Box) + } } } diff --git a/device-api/src/arch/renegade.rs b/device-api/src/arch/renegade.rs index de28749..fe0a107 100644 --- a/device-api/src/arch/renegade.rs +++ b/device-api/src/arch/renegade.rs @@ -14,7 +14,6 @@ use crate::DeviceError; #[derive(Clone, Debug)] pub struct RenegadeInner { - arch: Arch, devfile_index: u8, sysfs: PathBuf, mgmt_root: PathBuf, @@ -22,14 +21,13 @@ pub struct RenegadeInner { } impl RenegadeInner { - pub fn new(arch: Arch, devfile_index: u8, sysfs: PathBuf) -> DeviceResult { + pub fn new(devfile_index: u8, sysfs: PathBuf) -> DeviceResult { let mgmt_root = sysfs.join(format!( "class/renegade_mgmt/renegade!npu{devfile_index}mgmt" )); let mgmt_cache = MgmtCache::init(&mgmt_root, StaticMgmtFile::iter())?; Ok(RenegadeInner { - arch, devfile_index, sysfs, mgmt_root, @@ -80,7 +78,7 @@ impl DeviceMgmt for RenegadeInner { #[inline] fn arch(&self) -> Arch { - self.arch + Arch::Renegade } fn name(&self) -> String { @@ -171,8 +169,7 @@ mod tests { #[test] fn test_renegade_inner_functionality() -> eyre::Result<()> { - let device = - RenegadeInner::new(Arch::Renegade, 0, PathBuf::from("../test_data/test-1/sys"))?; + let device = RenegadeInner::new(0, PathBuf::from("../test_data/test-1/sys"))?; assert_eq!(device.devfile_index(), 0); assert_eq!(device.arch(), Arch::Renegade); diff --git a/device-api/src/arch/warboy.rs b/device-api/src/arch/warboy.rs index 079bffe..a5c0047 100644 --- a/device-api/src/arch/warboy.rs +++ b/device-api/src/arch/warboy.rs @@ -13,7 +13,6 @@ use crate::{Arch, ClockFrequency, DeviceError, DeviceFile}; #[derive(Clone, Debug)] pub struct WarboyInner { - arch: Arch, devfile_index: u8, sysfs: PathBuf, mgmt_root: PathBuf, @@ -21,12 +20,11 @@ pub struct WarboyInner { } impl WarboyInner { - pub fn new(arch: Arch, devfile_index: u8, sysfs: PathBuf) -> DeviceResult { + pub fn new(devfile_index: u8, sysfs: PathBuf) -> DeviceResult { let mgmt_root = sysfs.join(format!("class/npu_mgmt/npu{devfile_index}_mgmt")); let mgmt_cache = MgmtCache::init(&mgmt_root, StaticMgmtFile::iter())?; Ok(WarboyInner { - arch, devfile_index, sysfs, mgmt_root, @@ -75,8 +73,9 @@ impl DeviceMgmt for WarboyInner { self.devfile_index } + #[inline] fn arch(&self) -> Arch { - self.arch + Arch::WarboyB0 } fn name(&self) -> String { @@ -176,7 +175,7 @@ mod tests { #[test] fn test_warboy_inner_functionality() -> eyre::Result<()> { - let device = WarboyInner::new(Arch::WarboyB0, 0, PathBuf::from("../test_data/test-1/sys"))?; + let device = WarboyInner::new(0, PathBuf::from("../test_data/test-1/sys"))?; assert_eq!(device.devfile_index(), 0); assert_eq!(device.arch(), Arch::WarboyB0);