mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ryan Foster <foster.ryan.r@gmail.com>
To: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: ojeda@kernel.org, boqun.feng@gmail.com, gary@garyguo.net,
	bjorn3_gh@protonmail.com, lossin@kernel.org,
	a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
	gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
	linux-fsdevel@vger.kernel.org,
	Ryan Foster <foster.ryan.r@gmail.com>
Subject: [PATCH] rust: replace `kernel::c_str!` with C-Strings in seq_file and device
Date: Tue, 20 Jan 2026 06:02:35 -0800	[thread overview]
Message-ID: <20260120140235.126919-1-foster.ryan.r@gmail.com> (raw)

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

This patch updates seq_file and device modules to use the native
C-string literal syntax (c"...") instead of the kernel::c_str! macro.

Signed-off-by: Ryan Foster <foster.ryan.r@gmail.com>
---
 rust/kernel/device.rs   | 5 +----
 rust/kernel/seq_file.rs | 4 ++--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
index 71b200df0f40..1c3d1d962d15 100644
--- a/rust/kernel/device.rs
+++ b/rust/kernel/device.rs
@@ -12,9 +12,6 @@
 };
 use core::{any::TypeId, marker::PhantomData, ptr};
 
-#[cfg(CONFIG_PRINTK)]
-use crate::c_str;
-
 pub mod property;
 
 // Assert that we can `read()` / `write()` a `TypeId` instance from / into `struct driver_type`.
@@ -462,7 +459,7 @@ unsafe fn printk(&self, klevel: &[u8], msg: fmt::Arguments<'_>) {
             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/seq_file.rs b/rust/kernel/seq_file.rs
index 855e533813a6..518265558d66 100644
--- a/rust/kernel/seq_file.rs
+++ b/rust/kernel/seq_file.rs
@@ -4,7 +4,7 @@
 //!
 //! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.h)
 
-use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
+use crate::{bindings, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
 
 /// A utility for generating the contents of a seq file.
 #[repr(transparent)]
@@ -36,7 +36,7 @@ pub fn call_printf(&self, args: fmt::Arguments<'_>) {
         unsafe {
             bindings::seq_printf(
                 self.inner.get(),
-                c_str!("%pA").as_char_ptr(),
+                c"%pA".as_char_ptr(),
                 core::ptr::from_ref(&args).cast::<crate::ffi::c_void>(),
             );
         }
-- 
2.52.0


             reply	other threads:[~2026-01-20 14:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 14:02 Ryan Foster [this message]
2026-01-20 14:49 ` Gary Guo
2026-01-20 14:59   ` Ryan Foster
2026-01-20 15:02     ` Gary Guo
2026-01-20 21:11       ` Tamir Duberstein
2026-01-20 15:00   ` ryan foster

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=20260120140235.126919-1-foster.ryan.r@gmail.com \
    --to=foster.ryan.r@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fsdevel@vger.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=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

all inboxes | Powered by JetHome®