mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:04:41 +01:00
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>
This commit is contained in:
parent
6fc4b5eb63
commit
f0c6ea853b
2 changed files with 4 additions and 6 deletions
|
|
@ -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>(),
|
||||
)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue