Browse Source

acpi: provide `new` function directly on `PlatformInfo` too

Isaac Woods 1 year ago
parent
commit
f45963d3bc
2 changed files with 13 additions and 2 deletions
  1. 1 1
      acpi/src/lib.rs
  2. 12 1
      acpi/src/platform/mod.rs

+ 1 - 1
acpi/src/lib.rs

@@ -336,7 +336,7 @@ where
     /// Like `platform_info_in`, but uses the global allocator.
     #[cfg(feature = "alloc")]
     pub fn platform_info(&self) -> AcpiResult<PlatformInfo<alloc::alloc::Global>> {
-        PlatformInfo::new_in(self, alloc::alloc::Global)
+        PlatformInfo::new(self)
     }
 
     /// Convenience method for contructing a [`PlatformInfo`](crate::platform::PlatformInfo). This is one of the

+ 12 - 1
acpi/src/platform/mod.rs

@@ -6,6 +6,7 @@ use crate::{
     madt::Madt,
     AcpiError,
     AcpiHandler,
+    AcpiResult,
     AcpiTables,
     ManagedSlice,
     PowerProfile,
@@ -100,11 +101,21 @@ where
      */
 }
 
+#[cfg(feature = "alloc")]
+impl<'a> PlatformInfo<'a, alloc::alloc::Global> {
+    pub fn new<H>(tables: &AcpiTables<H>) -> AcpiResult<Self>
+    where
+        H: AcpiHandler,
+    {
+        Self::new_in(tables, alloc::alloc::Global)
+    }
+}
+
 impl<'a, A> PlatformInfo<'a, A>
 where
     A: Allocator + Clone,
 {
-    pub fn new_in<H>(tables: &AcpiTables<H>, allocator: A) -> crate::AcpiResult<Self>
+    pub fn new_in<H>(tables: &AcpiTables<H>, allocator: A) -> AcpiResult<Self>
     where
         H: AcpiHandler,
     {