From: Tamir Duberstein <tamird@kernel.org>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Dave Ertman" <david.m.ertman@intel.com>,
"Ira Weiny" <ira.weiny@intel.com>,
"Leon Romanovsky" <leon@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
Tamir Duberstein <tamird@gmail.com>
Subject: [PATCH 6/7] rust: debugfs: replace `kernel::c_str!` with C-Strings
Date: Mon, 22 Dec 2025 13:35:32 +0100 [thread overview]
Message-ID: <20251222-cstr-driver-core-v1-6-1142a177d0fd@gmail.com> (raw)
In-Reply-To: <20251222-cstr-driver-core-v1-0-1142a177d0fd@gmail.com>
From: Tamir Duberstein <tamird@gmail.com>
C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
rust/kernel/debugfs.rs | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/rust/kernel/debugfs.rs b/rust/kernel/debugfs.rs
index facad81e8290..fe7c8c5e3301 100644
--- a/rust/kernel/debugfs.rs
+++ b/rust/kernel/debugfs.rs
@@ -102,9 +102,8 @@ fn create_file<'a, T, E: 'a>(
/// # Examples
///
/// ```
- /// # use kernel::c_str;
/// # use kernel::debugfs::Dir;
- /// let debugfs = Dir::new(c_str!("parent"));
+ /// let debugfs = Dir::new(c"parent");
/// ```
pub fn new(name: &CStr) -> Self {
Dir::create(name, None)
@@ -115,10 +114,9 @@ pub fn new(name: &CStr) -> Self {
/// # Examples
///
/// ```
- /// # use kernel::c_str;
/// # use kernel::debugfs::Dir;
- /// let parent = Dir::new(c_str!("parent"));
- /// let child = parent.subdir(c_str!("child"));
+ /// let parent = Dir::new(c"parent");
+ /// let child = parent.subdir(c"child");
/// ```
pub fn subdir(&self, name: &CStr) -> Self {
Dir::create(name, Some(self))
@@ -132,11 +130,10 @@ pub fn subdir(&self, name: &CStr) -> Self {
/// # Examples
///
/// ```
- /// # use kernel::c_str;
/// # use kernel::debugfs::Dir;
/// # use kernel::prelude::*;
- /// # let dir = Dir::new(c_str!("my_debugfs_dir"));
- /// let file = KBox::pin_init(dir.read_only_file(c_str!("foo"), 200), GFP_KERNEL)?;
+ /// # let dir = Dir::new(c"my_debugfs_dir");
+ /// let file = KBox::pin_init(dir.read_only_file(c"foo", 200), GFP_KERNEL)?;
/// // "my_debugfs_dir/foo" now contains the number 200.
/// // The file is removed when `file` is dropped.
/// # Ok::<(), Error>(())
@@ -161,11 +158,10 @@ pub fn read_only_file<'a, T, E: 'a>(
/// # Examples
///
/// ```
- /// # use kernel::c_str;
/// # use kernel::debugfs::Dir;
/// # use kernel::prelude::*;
- /// # let dir = Dir::new(c_str!("my_debugfs_dir"));
- /// let file = KBox::pin_init(dir.read_binary_file(c_str!("foo"), [0x1, 0x2]), GFP_KERNEL)?;
+ /// # let dir = Dir::new(c"my_debugfs_dir");
+ /// let file = KBox::pin_init(dir.read_binary_file(c"foo", [0x1, 0x2]), GFP_KERNEL)?;
/// # Ok::<(), Error>(())
/// ```
pub fn read_binary_file<'a, T, E: 'a>(
@@ -188,12 +184,11 @@ pub fn read_binary_file<'a, T, E: 'a>(
///
/// ```
/// # use core::sync::atomic::{AtomicU32, Ordering};
- /// # use kernel::c_str;
/// # use kernel::debugfs::Dir;
/// # use kernel::prelude::*;
- /// # let dir = Dir::new(c_str!("foo"));
+ /// # let dir = Dir::new(c"foo");
/// let file = KBox::pin_init(
- /// dir.read_callback_file(c_str!("bar"),
+ /// dir.read_callback_file(c"bar",
/// AtomicU32::new(3),
/// &|val, f| {
/// let out = val.load(Ordering::Relaxed);
--
2.52.0
next prev parent reply other threads:[~2025-12-22 12:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 12:35 [PATCH 0/7] driver-core: rust: replace `kernel::c_str!` with C-Strings Tamir Duberstein
2025-12-22 12:35 ` [PATCH 1/7] rust: auxiliary: " Tamir Duberstein
2025-12-22 12:35 ` [PATCH 2/7] rust: device: " Tamir Duberstein
2025-12-22 12:35 ` [PATCH 3/7] rust: platform: " Tamir Duberstein
2025-12-22 12:35 ` [PATCH 4/7] rust: io: " Tamir Duberstein
2025-12-22 12:35 ` [PATCH 5/7] rust: irq: " Tamir Duberstein
2025-12-22 12:35 ` Tamir Duberstein [this message]
2025-12-22 12:35 ` [PATCH 7/7] samples: rust: debugfs: " Tamir Duberstein
2025-12-22 13:16 ` [PATCH 0/7] driver-core: rust: " Daniel Almeida
2025-12-22 16:46 ` Danilo Krummrich
2025-12-23 7:41 ` Tamir Duberstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251222-cstr-driver-core-v1-6-1142a177d0fd@gmail.com \
--to=tamird@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=david.m.ertman@intel.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@gmail.com \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox