[PATCH] rust: clk: replace `kernel::c_str!` with C-Strings

Tamir Duberstein posted 1 patch 1 month, 2 weeks ago
rust/kernel/clk.rs | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Tamir Duberstein 1 month, 2 weeks ago
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.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/clk.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
index c1cfaeaa36a2..68a0c2f4e318 100644
--- a/rust/kernel/clk.rs
+++ b/rust/kernel/clk.rs
@@ -104,13 +104,12 @@ mod common_clk {
     /// The following example demonstrates how to obtain and configure a clock for a device.
     ///
     /// ```
-    /// use kernel::c_str;
     /// use kernel::clk::{Clk, Hertz};
     /// use kernel::device::Device;
     /// use kernel::error::Result;
     ///
     /// fn configure_clk(dev: &Device) -> Result {
-    ///     let clk = Clk::get(dev, Some(c_str!("apb_clk")))?;
+    ///     let clk = Clk::get(dev, Some(c"apb_clk"))?;
     ///
     ///     clk.prepare_enable()?;
     ///
@@ -272,13 +271,12 @@ fn drop(&mut self) {
     /// device. The code functions correctly whether or not the clock is available.
     ///
     /// ```
-    /// use kernel::c_str;
     /// use kernel::clk::{OptionalClk, Hertz};
     /// use kernel::device::Device;
     /// use kernel::error::Result;
     ///
     /// fn configure_clk(dev: &Device) -> Result {
-    ///     let clk = OptionalClk::get(dev, Some(c_str!("apb_clk")))?;
+    ///     let clk = OptionalClk::get(dev, Some(c"apb_clk"))?;
     ///
     ///     clk.prepare_enable()?;
     ///

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-clk-122a1428b919

Best regards,
--  
Tamir Duberstein <tamird@gmail.com>
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Miguel Ojeda 1 week, 1 day ago
On Mon, Dec 22, 2025 at 1:17 PM Tamir Duberstein <tamird@kernel.org> wrote:
>
> 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.
>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Benno Lossin <lossin@kernel.org>
> Acked-by: Stephen Boyd <sboyd@kernel.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>

Applied to `rust-next` -- thanks everyone!

Cheers,
Miguel
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Daniel Almeida 1 month, 2 weeks ago

> On 22 Dec 2025, at 09:16, Tamir Duberstein <tamird@kernel.org> wrote:
> 
> 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.
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Benno Lossin <lossin@kernel.org>
> Acked-by: Stephen Boyd <sboyd@kernel.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
> rust/kernel/clk.rs | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> index c1cfaeaa36a2..68a0c2f4e318 100644
> --- a/rust/kernel/clk.rs
> +++ b/rust/kernel/clk.rs
> @@ -104,13 +104,12 @@ mod common_clk {
>     /// The following example demonstrates how to obtain and configure a clock for a device.
>     ///
>     /// ```
> -    /// use kernel::c_str;
>     /// use kernel::clk::{Clk, Hertz};
>     /// use kernel::device::Device;
>     /// use kernel::error::Result;
>     ///
>     /// fn configure_clk(dev: &Device) -> Result {
> -    ///     let clk = Clk::get(dev, Some(c_str!("apb_clk")))?;
> +    ///     let clk = Clk::get(dev, Some(c"apb_clk"))?;
>     ///
>     ///     clk.prepare_enable()?;
>     ///
> @@ -272,13 +271,12 @@ fn drop(&mut self) {
>     /// device. The code functions correctly whether or not the clock is available.
>     ///
>     /// ```
> -    /// use kernel::c_str;
>     /// use kernel::clk::{OptionalClk, Hertz};
>     /// use kernel::device::Device;
>     /// use kernel::error::Result;
>     ///
>     /// fn configure_clk(dev: &Device) -> Result {
> -    ///     let clk = OptionalClk::get(dev, Some(c_str!("apb_clk")))?;
> +    ///     let clk = OptionalClk::get(dev, Some(c"apb_clk"))?;
>     ///
>     ///     clk.prepare_enable()?;
>     ///
> 
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20251222-cstr-clk-122a1428b919
> 
> Best regards,
> --  
> Tamir Duberstein <tamird@gmail.com>
> 
> 

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Tamir Duberstein 1 month ago
On Mon, Dec 22, 2025 at 7:17 AM Tamir Duberstein <tamird@kernel.org> wrote:
>
> 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.
>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Benno Lossin <lossin@kernel.org>
> Acked-by: Stephen Boyd <sboyd@kernel.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> ---
>  rust/kernel/clk.rs | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> index c1cfaeaa36a2..68a0c2f4e318 100644
> --- a/rust/kernel/clk.rs
> +++ b/rust/kernel/clk.rs
> @@ -104,13 +104,12 @@ mod common_clk {
>      /// The following example demonstrates how to obtain and configure a clock for a device.
>      ///
>      /// ```
> -    /// use kernel::c_str;
>      /// use kernel::clk::{Clk, Hertz};
>      /// use kernel::device::Device;
>      /// use kernel::error::Result;
>      ///
>      /// fn configure_clk(dev: &Device) -> Result {
> -    ///     let clk = Clk::get(dev, Some(c_str!("apb_clk")))?;
> +    ///     let clk = Clk::get(dev, Some(c"apb_clk"))?;
>      ///
>      ///     clk.prepare_enable()?;
>      ///
> @@ -272,13 +271,12 @@ fn drop(&mut self) {
>      /// device. The code functions correctly whether or not the clock is available.
>      ///
>      /// ```
> -    /// use kernel::c_str;
>      /// use kernel::clk::{OptionalClk, Hertz};
>      /// use kernel::device::Device;
>      /// use kernel::error::Result;
>      ///
>      /// fn configure_clk(dev: &Device) -> Result {
> -    ///     let clk = OptionalClk::get(dev, Some(c_str!("apb_clk")))?;
> +    ///     let clk = OptionalClk::get(dev, Some(c"apb_clk"))?;
>      ///
>      ///     clk.prepare_enable()?;
>      ///
>
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20251222-cstr-clk-122a1428b919
>
> Best regards,
> --
> Tamir Duberstein <tamird@gmail.com>
>

@Stephen could you please have a look?

Cheers.
Tamir
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Tamir Duberstein 2 weeks, 5 days ago
On Sat, Jan 3, 2026 at 9:29 PM Tamir Duberstein <tamird@gmail.com> wrote:
>
> On Mon, Dec 22, 2025 at 7:17 AM Tamir Duberstein <tamird@kernel.org> wrote:
> >
> > 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.
> >
> > Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> > Reviewed-by: Benno Lossin <lossin@kernel.org>
> > Acked-by: Stephen Boyd <sboyd@kernel.org>
> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Tamir Duberstein <tamird@gmail.com>
> > ---
> >  rust/kernel/clk.rs | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs
> > index c1cfaeaa36a2..68a0c2f4e318 100644
> > --- a/rust/kernel/clk.rs
> > +++ b/rust/kernel/clk.rs
> > @@ -104,13 +104,12 @@ mod common_clk {
> >      /// The following example demonstrates how to obtain and configure a clock for a device.
> >      ///
> >      /// ```
> > -    /// use kernel::c_str;
> >      /// use kernel::clk::{Clk, Hertz};
> >      /// use kernel::device::Device;
> >      /// use kernel::error::Result;
> >      ///
> >      /// fn configure_clk(dev: &Device) -> Result {
> > -    ///     let clk = Clk::get(dev, Some(c_str!("apb_clk")))?;
> > +    ///     let clk = Clk::get(dev, Some(c"apb_clk"))?;
> >      ///
> >      ///     clk.prepare_enable()?;
> >      ///
> > @@ -272,13 +271,12 @@ fn drop(&mut self) {
> >      /// device. The code functions correctly whether or not the clock is available.
> >      ///
> >      /// ```
> > -    /// use kernel::c_str;
> >      /// use kernel::clk::{OptionalClk, Hertz};
> >      /// use kernel::device::Device;
> >      /// use kernel::error::Result;
> >      ///
> >      /// fn configure_clk(dev: &Device) -> Result {
> > -    ///     let clk = OptionalClk::get(dev, Some(c_str!("apb_clk")))?;
> > +    ///     let clk = OptionalClk::get(dev, Some(c"apb_clk"))?;
> >      ///
> >      ///     clk.prepare_enable()?;
> >      ///
> >
> > ---
> > base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> > change-id: 20251222-cstr-clk-122a1428b919
> >
> > Best regards,
> > --
> > Tamir Duberstein <tamird@gmail.com>
> >
>
> @Stephen could you please have a look?
>
> Cheers.
> Tamir

Michael or Stephen: could you take this through clk or would you be ok
with it going through rust-next?
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Miguel Ojeda 2 weeks, 4 days ago
On Mon, Jan 19, 2026 at 1:52 PM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Michael or Stephen: could you take this through clk or would you be ok
> with it going through rust-next?

Either seems good to me, thanks!

For context, this is part of a long migration:

    https://github.com/Rust-for-Linux/linux/issues/1075
    https://lore.kernel.org/all/20250704-core-cstr-prepare-v1-0-a91524037783@gmail.com/

Cheers,
Miguel
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Tamir Duberstein 1 week, 4 days ago
On Mon, Jan 19, 2026 at 1:00 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Mon, Jan 19, 2026 at 1:52 PM Tamir Duberstein <tamird@gmail.com> wrote:
> >
> > Michael or Stephen: could you take this through clk or would you be ok
> > with it going through rust-next?
>
> Either seems good to me, thanks!
>
> For context, this is part of a long migration:
>
>     https://github.com/Rust-for-Linux/linux/issues/1075
>     https://lore.kernel.org/all/20250704-core-cstr-prepare-v1-0-a91524037783@gmail.com/
>
> Cheers,
> Miguel

Another ping here, folks! Miguel, what can we do if we do not hear
from the clk maintainers?
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Miguel Ojeda 1 week, 4 days ago
On Tue, Jan 27, 2026 at 3:14 PM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Another ping here, folks! Miguel, what can we do if we do not hear
> from the clk maintainers?

Stephen already Acked-by this one, right?

So I assume they were OK with me taking it -- I will do that unless
someone shouts.

Thanks!

Cheers,
Miguel
Re: [PATCH] rust: clk: replace `kernel::c_str!` with C-Strings
Posted by Tamir Duberstein 1 week, 3 days ago
On Tue, Jan 27, 2026 at 9:27 AM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Tue, Jan 27, 2026 at 3:14 PM Tamir Duberstein <tamird@gmail.com> wrote:
> >
> > Another ping here, folks! Miguel, what can we do if we do not hear
> > from the clk maintainers?
>
> Stephen already Acked-by this one, right?
>
> So I assume they were OK with me taking it -- I will do that unless
> someone shouts.

Great, thanks!