Thread (15 messages) 15 messages, 4 authors, 2025-09-16
STALE313d

[PATCH v3 11/11] rust: acpi: use `core::ffi::CStr` method names

From: Tamir Duberstein <hidden>
Date: 2025-08-13 15:42:26
Also in: dri-devel, linux-acpi, linux-kselftest, linux-pm, lkml, netdev, rust-for-linux
Subsystem: acpi, rust, the rest · Maintainers: "Rafael J. Wysocki", Miguel Ojeda, Linus Torvalds

Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by
avoid methods that only exist on the latter.

Signed-off-by: Tamir Duberstein <redacted>
---
 rust/kernel/acpi.rs | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/rust/kernel/acpi.rs b/rust/kernel/acpi.rs
index 7ae317368b00..37e1161c1298 100644
--- a/rust/kernel/acpi.rs
+++ b/rust/kernel/acpi.rs
@@ -37,11 +37,8 @@ impl DeviceId {
     /// Create a new device id from an ACPI 'id' string.
     #[inline(always)]
     pub const fn new(id: &'static CStr) -> Self {
-        build_assert!(
-            id.len_with_nul() <= Self::ACPI_ID_LEN,
-            "ID exceeds 16 bytes"
-        );
-        let src = id.as_bytes_with_nul();
+        let src = id.to_bytes_with_nul();
+        build_assert!(src.len() <= 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() };
-- 
2.50.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help