Re: [PATCH v8 4/9] rust: acpi: add `acpi::DeviceId` abstraction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/20/25 5:24 PM, Igor Korotin wrote:
+impl DeviceId {
+    const ACPI_ID_LEN: usize = 16;
+
+    /// Create a new device id from an ACPI 'id' string.
+    pub const fn new<const N: usize>(id: &[u8; N]) -> Self {

Didn't notice before, but why was this silently changed from &CStr to &[u8; N]
from v6 to v7?

+        build_assert!(N <= Self::ACPI_ID_LEN, "ID exceeds 16 bytes");
+        // Replace with `bindings::acpi_device_id::default()` once stabilized for `const`.
+        // SAFETY: FFI type is valid to be zero-initialized.
+        let mut acpi: bindings::acpi_device_id = unsafe { core::mem::zeroed() };
+        let mut i = 0;
+        while i < N {
+            acpi.id[i] = id[i];
+            i += 1;
+        }
+
+        Self(acpi)
+    }
+}




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux