Skip to contentSkip to conversation

driver-core: rust: replace `kernel::c_str!` with C-Strings

PATCH In review Tamir Duberstein 3 participants 11 messages Dec 22, 2025 – Dec 23, 2025

Subsystems (4)
lore
Share & tools
lore

Tamir Duberstein

author reviewer
#0 lore raw

cover driver-core: rust: 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.

---
Tamir Duberstein (7):
rust: auxiliary: replace kernel::c_str! with C-Strings
rust: device: replace kernel::c_str! with C-Strings
rust: platform: replace kernel::c_str! with C-Strings
rust: io: replace kernel::c_str! with C-Strings
rust: irq: replace kernel::c_str! with C-Strings
rust: debugfs: replace kernel::c_str! with C-Strings
samples: rust: debugfs: replace kernel::c_str! with C-Strings

 rust/kernel/debugfs.rs                | 23 +++++++++--------------
 rust/kernel/device.rs                 |  4 +---
 rust/kernel/device/property.rs        |  6 +++---
 rust/kernel/io/mem.rs                 |  7 +++----
 rust/kernel/irq/request.rs            |  6 ++----
 rust/kernel/platform.rs               |  6 +++---
 samples/rust/rust_debugfs.rs          | 17 ++++++++---------
 samples/rust/rust_debugfs_scoped.rs   | 20 ++++++++------------
 samples/rust/rust_driver_auxiliary.rs |  4 ++--
 samples/rust/rust_driver_faux.rs      |  4 ++--
 samples/rust/rust_driver_platform.rs  | 30 ++++++++++++++----------------
 11 files changed, 55 insertions(+), 72 deletions(-)

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-driver-core-8bf66543f532

Best regards,

Signature · 1 line
Tamir Duberstein <[email protected]>
author reviewer
#1 lore raw

PATCH 1/7 rust: auxiliary: replace `kernel::c_str!` with C-Strings

From: Tamir Duberstein <[email protected]>

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

---
 samples/rust/rust_driver_auxiliary.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
samples/rust/rust_driver_auxiliary.rs +2 -2
index 5761ea314f44..1e4fb23cfcb0 100644
@@ -5,7 +5,7 @@
 //! To make this driver probe, QEMU must be run with `-device pci-testdev`.
 
 use kernel::{
-    auxiliary, c_str,
+    auxiliary,
     device::{Bound, Core},
     devres::Devres,
     driver,
@@ -19,7 +19,7 @@
 use pin_init::PinInit;
 
 const MODULE_NAME: &CStr = <LocalModule as kernel::ModuleMetadata>::NAME;
-const AUXILIARY_NAME: &CStr = c_str!("auxiliary");
+const AUXILIARY_NAME: &CStr = c"auxiliary";
 
 struct AuxiliaryDriver;
 
Signature · 1 line
2.52.0
author reviewer
#2 lore raw

PATCH 2/7 rust: device: replace `kernel::c_str!` with C-Strings

In reply to Tamir Duberstein

From: Tamir Duberstein <[email protected]>

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

---
 rust/kernel/device.rs          | 4 +---
 rust/kernel/device/property.rs | 6 +++---
 2 files changed, 4 insertions(+), 6 deletions(-)
rust/kernel/device.rs +1 -3
index c79be2e2bfe3..d4edceaf3020 100644
@@ -12,8 +12,6 @@
 };
 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 @@ 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>(),
             )
         };
rust/kernel/device/property.rs +3 -3
index 3a332a8c53a9..3eb3f36d66d0 100644
@@ -178,11 +178,11 @@ pub fn property_count_elem<T: PropertyInt>(&self, name: &CStr) -> Result<usize>
     /// # 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(())
Signature · 1 line
2.52.0
author reviewer
#3 lore raw

PATCH 3/7 rust: platform: replace `kernel::c_str!` with C-Strings

In reply to Tamir Duberstein

From: Tamir Duberstein <[email protected]>

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

---
 rust/kernel/platform.rs              |  6 +++---
 samples/rust/rust_driver_faux.rs     |  4 ++--
 samples/rust/rust_driver_platform.rs | 30 ++++++++++++++----------------
 3 files changed, 19 insertions(+), 21 deletions(-)
rust/kernel/platform.rs +3 -3
index ed889f079cab..abb22a787131 100644
@@ -137,7 +137,7 @@ macro_rules! module_platform_driver {
 /// # Examples
 ///
 ///```
-/// # use kernel::{acpi, bindings, c_str, device::Core, of, platform};
+/// # use kernel::{acpi, bindings, device::Core, of, platform};
 ///
 /// struct MyDriver;
 ///
@@ -146,7 +146,7 @@ macro_rules! module_platform_driver {
 ///     MODULE_OF_TABLE,
 ///     <MyDriver as platform::Driver>::IdInfo,
 ///     [
-///         (of::DeviceId::new(c_str!("test,device")), ())
+///         (of::DeviceId::new(c"test,device"), ())
 ///     ]
 /// );
 ///
@@ -155,7 +155,7 @@ macro_rules! module_platform_driver {
 ///     MODULE_ACPI_TABLE,
 ///     <MyDriver as platform::Driver>::IdInfo,
 ///     [
-///         (acpi::DeviceId::new(c_str!("LNUXBEEF")), ())
+///         (acpi::DeviceId::new(c"LNUXBEEF"), ())
 ///     ]
 /// );
 ///
samples/rust/rust_driver_faux.rs +2 -2
index ecc9fd378cbd..23add3160693 100644
@@ -2,7 +2,7 @@
 
 //! Rust faux device sample.
 
-use kernel::{c_str, faux, prelude::*, Module};
+use kernel::{faux, prelude::*, Module};
 
 module! {
     type: SampleModule,
@@ -20,7 +20,7 @@ impl Module for SampleModule {
     fn init(_module: &'static ThisModule) -> Result<Self> {
         pr_info!("Initialising Rust Faux Device Sample\n");
 
-        let reg = faux::Registration::new(c_str!("rust-faux-sample-device"), None)?;
+        let reg = faux::Registration::new(c"rust-faux-sample-device", None)?;
 
         dev_info!(reg.as_ref(), "Hello from faux device!\n");
 
samples/rust/rust_driver_platform.rs +14 -16
index 6bf4f0c9633d..a3044d773176 100644
@@ -63,7 +63,7 @@
 //!
 
 use kernel::{
-    acpi, c_str,
+    acpi,
     device::{
         self,
         property::{FwNodeReferenceArgs, NArgs},
@@ -85,14 +85,14 @@ struct SampleDriver {
     OF_TABLE,
     MODULE_OF_TABLE,
     <SampleDriver as platform::Driver>::IdInfo,
-    [(of::DeviceId::new(c_str!("test,rust-device")), Info(42))]
+    [(of::DeviceId::new(c"test,rust-device"), Info(42))]
 );
 
 kernel::acpi_device_table!(
     ACPI_TABLE,
     MODULE_ACPI_TABLE,
     <SampleDriver as platform::Driver>::IdInfo,
-    [(acpi::DeviceId::new(c_str!("LNUXBEEF")), Info(0))]
+    [(acpi::DeviceId::new(c"LNUXBEEF"), Info(0))]
 );
 
 impl platform::Driver for SampleDriver {
@@ -124,49 +124,47 @@ impl SampleDriver {
     fn properties_parse(dev: &device::Device) -> Result {
         let fwnode = dev.fwnode().ok_or(ENOENT)?;
 
-        if let Ok(idx) =
-            fwnode.property_match_string(c_str!("compatible"), c_str!("test,rust-device"))
-        {
+        if let Ok(idx) = fwnode.property_match_string(c"compatible", c"test,rust-device") {
             dev_info!(dev, "matched compatible string idx = {}\n", idx);
         }
 
-        let name = c_str!("compatible");
+        let name = c"compatible";
         let prop = fwnode.property_read::<CString>(name).required_by(dev)?;
         dev_info!(dev, "'{name}'='{prop:?}'\n");
 
-        let name = c_str!("test,bool-prop");
-        let prop = fwnode.property_read_bool(c_str!("test,bool-prop"));
+        let name = c"test,bool-prop";
+        let prop = fwnode.property_read_bool(c"test,bool-prop");
         dev_info!(dev, "'{name}'='{prop}'\n");
 
-        if fwnode.property_present(c_str!("test,u32-prop")) {
+        if fwnode.property_present(c"test,u32-prop") {
             dev_info!(dev, "'test,u32-prop' is present\n");
         }
 
-        let name = c_str!("test,u32-optional-prop");
+        let name = c"test,u32-optional-prop";
         let prop = fwnode.property_read::<u32>(name).or(0x12);
         dev_info!(dev, "'{name}'='{prop:#x}' (default = 0x12)\n");
 
         // A missing required property will print an error. Discard the error to
         // prevent properties_parse from failing in that case.
-        let name = c_str!("test,u32-required-prop");
+        let name = c"test,u32-required-prop";
         let _ = fwnode.property_read::<u32>(name).required_by(dev);
 
-        let name = c_str!("test,u32-prop");
+        let name = c"test,u32-prop";
         let prop: u32 = fwnode.property_read(name).required_by(dev)?;
         dev_info!(dev, "'{name}'='{prop:#x}'\n");
 
-        let name = c_str!("test,i16-array");
+        let name = c"test,i16-array";
         let prop: [i16; 4] = fwnode.property_read(name).required_by(dev)?;
         dev_info!(dev, "'{name}'='{prop:?}'\n");
         let len = fwnode.property_count_elem::<u16>(name)?;
         dev_info!(dev, "'{name}' length is {len}\n");
 
-        let name = c_str!("test,i16-array");
+        let name = c"test,i16-array";
         let prop: KVec<i16> = fwnode.property_read_array_vec(name, 4)?.required_by(dev)?;
         dev_info!(dev, "'{name}'='{prop:?}' (KVec)\n");
 
         for child in fwnode.children() {
-            let name = c_str!("test,ref-arg");
+            let name = c"test,ref-arg";
             let nargs = NArgs::N(2);
             let prop: FwNodeReferenceArgs = child.property_get_reference_args(name, nargs, 0)?;
             dev_info!(dev, "'{name}'='{prop:?}'\n");
Signature · 1 line
2.52.0
author reviewer
#4 lore raw

PATCH 4/7 rust: io: replace `kernel::c_str!` with C-Strings

In reply to Tamir Duberstein

From: Tamir Duberstein <[email protected]>

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

---
 rust/kernel/io/mem.rs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
rust/kernel/io/mem.rs +3 -4
index b03b82cd531b..3b131f6f7733 100644
@@ -5,7 +5,6 @@
 use core::ops::Deref;
 
 use crate::{
-    c_str,
     device::{
         Bound,
         Device, //
@@ -52,7 +51,7 @@ pub(crate) unsafe fn new(device: &'a Device<Bound>, resource: &'a Resource) -> S
     /// illustration purposes.
     ///
     /// ```no_run
-    /// use kernel::{bindings, c_str, platform, of, device::Core};
+    /// use kernel::{bindings, platform, of, device::Core};
     /// struct SampleDriver;
     ///
     /// impl platform::Driver for SampleDriver {
@@ -110,7 +109,7 @@ pub fn iomap_exclusive_sized<const SIZE: usize>(
     /// illustration purposes.
     ///
     /// ```no_run
-    /// use kernel::{bindings, c_str, platform, of, device::Core};
+    /// use kernel::{bindings, platform, of, device::Core};
     /// struct SampleDriver;
     ///
     /// impl platform::Driver for SampleDriver {
@@ -172,7 +171,7 @@ impl<const SIZE: usize> ExclusiveIoMem<SIZE> {
     fn ioremap(resource: &Resource) -> Result<Self> {
         let start = resource.start();
         let size = resource.size();
-        let name = resource.name().unwrap_or(c_str!(""));
+        let name = resource.name().unwrap_or_default();
 
         let region = resource
             .request_region(
Signature · 1 line
2.52.0
author reviewer
#5 lore raw

PATCH 5/7 rust: irq: replace `kernel::c_str!` with C-Strings

In reply to Tamir Duberstein

From: Tamir Duberstein <[email protected]>

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

---
 rust/kernel/irq/request.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
rust/kernel/irq/request.rs +2 -4
index b150563fdef8..67769800117c 100644
@@ -139,7 +139,6 @@ pub fn irq(&self) -> u32 {
 /// [`Completion::wait_for_completion()`]: kernel::sync::Completion::wait_for_completion
 ///
 /// ```
-/// use kernel::c_str;
 /// use kernel::device::{Bound, Device};
 /// use kernel::irq::{self, Flags, IrqRequest, IrqReturn, Registration};
 /// use kernel::prelude::*;
@@ -167,7 +166,7 @@ pub fn irq(&self) -> u32 {
 ///     handler: impl PinInit<Data, Error>,
 ///     request: IrqRequest<'_>,
 /// ) -> Result<Arc<Registration<Data>>> {
-///     let registration = Registration::new(request, Flags::SHARED, c_str!("my_device"), handler);
+///     let registration = Registration::new(request, Flags::SHARED, c"my_device", handler);
 ///
 ///     let registration = Arc::pin_init(registration, GFP_KERNEL)?;
 ///
@@ -340,7 +339,6 @@ fn handle_threaded(&self, device: &Device<Bound>) -> IrqReturn {
 /// [`Mutex`](kernel::sync::Mutex) to provide interior mutability.
 ///
 /// ```
-/// use kernel::c_str;
 /// use kernel::device::{Bound, Device};
 /// use kernel::irq::{
 ///   self, Flags, IrqRequest, IrqReturn, ThreadedHandler, ThreadedIrqReturn,
@@ -381,7 +379,7 @@ fn handle_threaded(&self, device: &Device<Bound>) -> IrqReturn {
 ///     request: IrqRequest<'_>,
 /// ) -> Result<Arc<ThreadedRegistration<Data>>> {
 ///     let registration =
-///         ThreadedRegistration::new(request, Flags::SHARED, c_str!("my_device"), handler);
+///         ThreadedRegistration::new(request, Flags::SHARED, c"my_device", handler);
 ///
 ///     let registration = Arc::pin_init(registration, GFP_KERNEL)?;
 ///
Signature · 1 line
2.52.0
author reviewer
#6 lore raw

PATCH 6/7 rust: debugfs: replace `kernel::c_str!` with C-Strings

In reply to Tamir Duberstein

From: Tamir Duberstein <[email protected]>

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

---
 rust/kernel/debugfs.rs | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
rust/kernel/debugfs.rs +9 -14
index facad81e8290..fe7c8c5e3301 100644
@@ -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);
Signature · 1 line
2.52.0
author reviewer
#7 lore raw

PATCH 7/7 samples: rust: debugfs: replace `kernel::c_str!` with C-Strings

In reply to Tamir Duberstein

From: Tamir Duberstein <[email protected]>

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

---
 samples/rust/rust_debugfs.rs        | 17 ++++++++---------
 samples/rust/rust_debugfs_scoped.rs | 20 ++++++++------------
 2 files changed, 16 insertions(+), 21 deletions(-)
samples/rust/rust_debugfs.rs +8 -9
index 025e8f9d12de..2888619443d3 100644
@@ -32,7 +32,6 @@
 //! ```
 
 use core::str::FromStr;
-use kernel::c_str;
 use kernel::debugfs::{Dir, File};
 use kernel::new_mutex;
 use kernel::prelude::*;
@@ -98,7 +97,7 @@ fn from_str(s: &str) -> Result<Self> {
     ACPI_TABLE,
     MODULE_ACPI_TABLE,
     <RustDebugFs as platform::Driver>::IdInfo,
-    [(acpi::DeviceId::new(c_str!("LNUXBEEF")), ())]
+    [(acpi::DeviceId::new(c"LNUXBEEF"), ())]
 );
 
 impl platform::Driver for RustDebugFs {
@@ -125,34 +124,34 @@ fn probe(
 
 impl RustDebugFs {
     fn build_counter(dir: &Dir) -> impl PinInit<File<Atomic<usize>>> + '_ {
-        dir.read_write_file(c_str!("counter"), Atomic::<usize>::new(0))
+        dir.read_write_file(c"counter", Atomic::<usize>::new(0))
     }
 
     fn build_inner(dir: &Dir) -> impl PinInit<File<Mutex<Inner>>> + '_ {
-        dir.read_write_file(c_str!("pair"), new_mutex!(Inner { x: 3, y: 10 }))
+        dir.read_write_file(c"pair", new_mutex!(Inner { x: 3, y: 10 }))
     }
 
     fn new(pdev: &platform::Device<Core>) -> impl PinInit<Self, Error> + '_ {
-        let debugfs = Dir::new(c_str!("sample_debugfs"));
+        let debugfs = Dir::new(c"sample_debugfs");
         let dev = pdev.as_ref();
 
         try_pin_init! {
             Self {
                 _compatible <- debugfs.read_only_file(
-                    c_str!("compatible"),
+                    c"compatible",
                     dev.fwnode()
                         .ok_or(ENOENT)?
-                        .property_read::<CString>(c_str!("compatible"))
+                        .property_read::<CString>(c"compatible")
                         .required_by(dev)?,
                 ),
                 counter <- Self::build_counter(&debugfs),
                 inner <- Self::build_inner(&debugfs),
                 array_blob <- debugfs.read_write_binary_file(
-                    c_str!("array_blob"),
+                    c"array_blob",
                     new_mutex!([0x62, 0x6c, 0x6f, 0x62]),
                 ),
                 vector_blob <- debugfs.read_write_binary_file(
-                    c_str!("vector_blob"),
+                    c"vector_blob",
                     new_mutex!(kernel::kvec!(0x42; SZ_4K)?),
                 ),
                 _debugfs: debugfs,
samples/rust/rust_debugfs_scoped.rs +8 -12
index 702a6546d3fb..358c47bae4d0 100644
@@ -11,7 +11,7 @@
 use kernel::sizes::*;
 use kernel::sync::atomic::Atomic;
 use kernel::sync::Mutex;
-use kernel::{c_str, new_mutex, str::CString};
+use kernel::{new_mutex, str::CString};
 
 module! {
     type: RustScopedDebugFs,
@@ -80,7 +80,7 @@ fn create_file_write(
                     };
                     dir.read_write_file(&name, val);
                 }
-                dir.read_write_binary_file(c_str!("blob"), &dev_data.blob);
+                dir.read_write_binary_file(c"blob", &dev_data.blob);
             },
         ),
         GFP_KERNEL,
@@ -119,20 +119,16 @@ struct DeviceData {
 }
 
 fn init_control(base_dir: &Dir, dyn_dirs: Dir) -> impl PinInit<Scope<ModuleData>> + '_ {
-    base_dir.scope(
-        ModuleData::init(dyn_dirs),
-        c_str!("control"),
-        |data, dir| {
-            dir.write_only_callback_file(c_str!("create"), data, &create_file_write);
-            dir.write_only_callback_file(c_str!("remove"), data, &remove_file_write);
-        },
-    )
+    base_dir.scope(ModuleData::init(dyn_dirs), c"control", |data, dir| {
+        dir.write_only_callback_file(c"create", data, &create_file_write);
+        dir.write_only_callback_file(c"remove", data, &remove_file_write);
+    })
 }
 
 impl kernel::Module for RustScopedDebugFs {
     fn init(_module: &'static kernel::ThisModule) -> Result<Self> {
-        let base_dir = Dir::new(c_str!("rust_scoped_debugfs"));
-        let dyn_dirs = base_dir.subdir(c_str!("dynamic"));
+        let base_dir = Dir::new(c"rust_scoped_debugfs");
+        let dyn_dirs = base_dir.subdir(c"dynamic");
         Ok(Self {
             _data: KBox::pin_init(init_control(&base_dir, dyn_dirs), GFP_KERNEL)?,
         })
Signature · 1 line
2.52.0
maintainer Reviewed-by on the v1 series
#8 lore raw
In reply to Tamir Duberstein
Quoted 30 lines · Tamir Duberstein

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

---
Tamir Duberstein (7):
rust: auxiliary: replace kernel::c_str! with C-Strings
rust: device: replace kernel::c_str! with C-Strings
rust: platform: replace kernel::c_str! with C-Strings
rust: io: replace kernel::c_str! with C-Strings
rust: irq: replace kernel::c_str! with C-Strings
rust: debugfs: replace kernel::c_str! with C-Strings
samples: rust: debugfs: replace kernel::c_str! with C-Strings

rust/kernel/debugfs.rs                | 23 +++++++++--------------
rust/kernel/device.rs                 |  4 +---
rust/kernel/device/property.rs        |  6 +++---
rust/kernel/io/mem.rs                 |  7 +++----
rust/kernel/irq/request.rs            |  6 ++----
rust/kernel/platform.rs               |  6 +++---
samples/rust/rust_debugfs.rs          | 17 ++++++++---------
samples/rust/rust_debugfs_scoped.rs   | 20 ++++++++------------
samples/rust/rust_driver_auxiliary.rs |  4 ++--
samples/rust/rust_driver_faux.rs      |  4 ++--
samples/rust/rust_driver_platform.rs  | 30 ++++++++++++++----------------
11 files changed, 55 insertions(+), 72 deletions(-)
Quoted 8 lines

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-driver-core-8bf66543f532

Best regards,

Signature · 1 line
Tamir Duberstein <[email protected]>
maintainer
#9 lore raw
In reply to Tamir Duberstein

On Mon Dec 22, 2025 at 1:35 PM CET, Tamir Duberstein wrote:

Applied to driver-core-testing, thanks!

Quoted 4 lines

Tamir Duberstein (7):
rust: auxiliary: replace kernel::c_str! with C-Strings
rust: device: replace kernel::c_str! with C-Strings
rust: platform: replace kernel::c_str! with C-Strings

[ Use kernel vertical import style; discard unrelated faux changes.
- Danilo ]

Quoted 1 line

rust: io: replace kernel::c_str! with C-Strings

[ Use kernel vertical import style. - Danilo ]

Quoted 3 lines

rust: irq: replace kernel::c_str! with C-Strings
rust: debugfs: replace kernel::c_str! with C-Strings
samples: rust: debugfs: replace kernel::c_str! with C-Strings

@Tamir: Can you please send a separate patch for the faux bus?

author reviewer
#10 lore raw
Quoted 15 lines · Danilo Krummrich

On Mon Dec 22, 2025 at 1:35 PM CET, Tamir Duberstein wrote:

Applied to driver-core-testing, thanks!

Quoted 4 lines

Tamir Duberstein (7):
rust: auxiliary: replace kernel::c_str! with C-Strings
rust: device: replace kernel::c_str! with C-Strings
rust: platform: replace kernel::c_str! with C-Strings

[ Use kernel vertical import style; discard unrelated faux changes.
- Danilo ]

Quoted 1 line

rust: io: replace kernel::c_str! with C-Strings

Quoted 7 lines

[ Use kernel vertical import style. - Danilo ]

Quoted 3 lines

rust: irq: replace kernel::c_str! with C-Strings
rust: debugfs: replace kernel::c_str! with C-Strings
samples: rust: debugfs: replace kernel::c_str! with C-Strings

@Tamir: Can you please send a separate patch for the faux bus?

Sure!

https://lore.kernel.org/all/[email protected]/