Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: device: replace `kernel::c_str!` with C-Strings

C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

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>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://patch.msgid.link/20251222-cstr-driver-core-v1-2-1142a177d0fd@gmail.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Tamir Duberstein and committed by
Danilo Krummrich
f0c6ea85 6fc4b5eb

+4 -6
+1 -3
rust/kernel/device.rs
··· 12 12 }; 13 13 use core::{any::TypeId, marker::PhantomData, ptr}; 14 14 15 - #[cfg(CONFIG_PRINTK)] 16 - use crate::c_str; 17 15 use crate::str::CStrExt as _; 18 16 19 17 pub mod property; ··· 461 463 bindings::_dev_printk( 462 464 klevel.as_ptr().cast::<crate::ffi::c_char>(), 463 465 self.as_raw(), 464 - c_str!("%pA").as_char_ptr(), 466 + c"%pA".as_char_ptr(), 465 467 core::ptr::from_ref(&msg).cast::<crate::ffi::c_void>(), 466 468 ) 467 469 };
+3 -3
rust/kernel/device/property.rs
··· 179 179 /// # Examples 180 180 /// 181 181 /// ``` 182 - /// # use kernel::{c_str, device::{Device, property::FwNode}, str::CString}; 182 + /// # use kernel::{device::{Device, property::FwNode}, str::CString}; 183 183 /// fn examples(dev: &Device) -> Result { 184 184 /// let fwnode = dev.fwnode().ok_or(ENOENT)?; 185 - /// let b: u32 = fwnode.property_read(c_str!("some-number")).required_by(dev)?; 186 - /// if let Some(s) = fwnode.property_read::<CString>(c_str!("some-str")).optional() { 185 + /// let b: u32 = fwnode.property_read(c"some-number").required_by(dev)?; 186 + /// if let Some(s) = fwnode.property_read::<CString>(c"some-str").optional() { 187 187 /// // ... 188 188 /// } 189 189 /// Ok(())