rust: of: use `core::ffi::CStr` method names
authorTamir Duberstein <tamird@gmail.com>
Wed, 13 Aug 2025 15:42:01 +0000 (11:42 -0400)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 16 Sep 2025 07:26:59 +0000 (09:26 +0200)
Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by
avoid methods that only exist on the latter.

Link: https://github.com/Rust-for-Linux/linux/issues/1075
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/of.rs

index b76b352..58b20c3 100644 (file)
@@ -34,7 +34,7 @@ unsafe impl RawDeviceIdIndex for DeviceId {
 impl DeviceId {
     /// Create a new device id from an OF 'compatible' string.
     pub const fn new(compatible: &'static CStr) -> Self {
-        let src = compatible.as_bytes_with_nul();
+        let src = compatible.to_bytes_with_nul();
         // Replace with `bindings::of_device_id::default()` once stabilized for `const`.
         // SAFETY: FFI type is valid to be zero-initialized.
         let mut of: bindings::of_device_id = unsafe { core::mem::zeroed() };