summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@gmail.com>2025-12-22 13:35:28 +0100
committerDanilo Krummrich <dakr@kernel.org>2025-12-22 17:30:24 +0100
commitf0c6ea853bd7f48aeec231e9378fc17cf36b9109 (patch)
tree9ad8504b8aa86ff69fe69716356e1e69cab10413 /rust/kernel
parent6fc4b5eb63c7c4c1f2251277ad1f0d04ac047d91 (diff)
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>
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/device.rs4
-rw-r--r--rust/kernel/device/property.rs6
2 files changed, 4 insertions, 6 deletions
diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
index 21bde8d95185..a13f6ee24b09 100644
--- a/rust/kernel/device.rs
+++ b/rust/kernel/device.rs
@@ -12,8 +12,6 @@ use crate::{
};
use core::{any::TypeId, marker::PhantomData, ptr};
-#[cfg(CONFIG_PRINTK)]
-use crate::c_str;
use crate::str::CStrExt as _;
pub mod property;
@@ -463,7 +461,7 @@ impl<Ctx: DeviceContext> Device<Ctx> {
bindings::_dev_printk(
klevel.as_ptr().cast::<crate::ffi::c_char>(),
self.as_raw(),
- c_str!("%pA").as_char_ptr(),
+ c"%pA".as_char_ptr(),
core::ptr::from_ref(&msg).cast::<crate::ffi::c_void>(),
)
};
diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs
index 413221817ef1..5aead835fbbc 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -179,11 +179,11 @@ impl FwNode {
/// # Examples
///
/// ```
- /// # use kernel::{c_str, device::{Device, property::FwNode}, str::CString};
+ /// # use kernel::{device::{Device, property::FwNode}, str::CString};
/// fn examples(dev: &Device) -> Result {
/// let fwnode = dev.fwnode().ok_or(ENOENT)?;
- /// let b: u32 = fwnode.property_read(c_str!("some-number")).required_by(dev)?;
- /// if let Some(s) = fwnode.property_read::<CString>(c_str!("some-str")).optional() {
+ /// let b: u32 = fwnode.property_read(c"some-number").required_by(dev)?;
+ /// if let Some(s) = fwnode.property_read::<CString>(c"some-str").optional() {
/// // ...
/// }
/// Ok(())