rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}`
@ 2025-07-19 22:41 Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 1/8] gpu: nova-core: " Tamir Duberstein
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

This is series 2a/5 of the migration to `core::ffi::CStr`[0].
20250704-core-cstr-prepare-v1-0-a91524037783@gmail.com.

This series depends on the prior series[0] and is intended to go through
the rust tree to reduce the number of release cycles required to
complete the work.

Subsystem maintainers: I would appreciate your `Acked-by`s so that this
can be taken through Miguel's tree (where the other series must go).

[0] https://lore.kernel.org/all/20250704-core-cstr-prepare-v1-0-a91524037783@gmail.com/

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
Changes in v2:
- Rebase on rust-next.
- Drop pin-init patch, which is no longer needed.
- Link to v1: https://lore.kernel.org/r/20250709-core-cstr-fanout-1-v1-0-64308e7203fc@gmail.com

---
Tamir Duberstein (8):
      gpu: nova-core: use `kernel::{fmt,prelude::fmt!}`
      rust: alloc: use `kernel::{fmt,prelude::fmt!}`
      rust: block: use `kernel::{fmt,prelude::fmt!}`
      rust: device: use `kernel::{fmt,prelude::fmt!}`
      rust: file: use `kernel::{fmt,prelude::fmt!}`
      rust: kunit: use `kernel::{fmt,prelude::fmt!}`
      rust: seq_file: use `kernel::{fmt,prelude::fmt!}`
      rust: sync: use `kernel::{fmt,prelude::fmt!}`

 drivers/block/rnull.rs               | 2 +-
 drivers/gpu/nova-core/gpu.rs         | 3 +--
 drivers/gpu/nova-core/regs/macros.rs | 6 +++---
 rust/kernel/alloc/kbox.rs            | 2 +-
 rust/kernel/alloc/kvec.rs            | 2 +-
 rust/kernel/alloc/kvec/errors.rs     | 2 +-
 rust/kernel/block/mq.rs              | 2 +-
 rust/kernel/block/mq/gen_disk.rs     | 2 +-
 rust/kernel/block/mq/raw_writer.rs   | 3 +--
 rust/kernel/device.rs                | 6 +++---
 rust/kernel/fs/file.rs               | 5 +++--
 rust/kernel/kunit.rs                 | 8 ++++----
 rust/kernel/seq_file.rs              | 6 +++---
 rust/kernel/sync/arc.rs              | 2 +-
 scripts/rustdoc_test_gen.rs          | 2 +-
 15 files changed, 26 insertions(+), 27 deletions(-)
---
base-commit: cc84ef3b88f407e8bd5a5f7b6906d1e69851c856
change-id: 20250709-core-cstr-fanout-1-f20611832272
prerequisite-change-id: 20250704-core-cstr-prepare-9b9e6a7bd57e:v1
prerequisite-patch-id: 83b1239d1805f206711a5a936bbb61c83227d573
prerequisite-patch-id: a0355dd0efcc945b0565dc4e5a0f42b5a3d29c7e
prerequisite-patch-id: 8585bf441cfab705181f5606c63483c2e88d25aa
prerequisite-patch-id: 04ec344c0bc23f90dbeac10afe26df1a86ce53ec
prerequisite-patch-id: a2fc6cd05fce6d6da8d401e9f8a905bb5c0b2f27
prerequisite-patch-id: f14c099c87562069f25fb7aea6d9aae4086c49a8

Best regards,
--  
Tamir Duberstein <tamird@gmail.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/8] gpu: nova-core: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 2/8] rust: alloc: " Tamir Duberstein
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 drivers/gpu/nova-core/gpu.rs         | 3 +--
 drivers/gpu/nova-core/regs/macros.rs | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 60b86f370284..f1d72da7fddd 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -1,12 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
 
-use kernel::{device, devres::Devres, error::code::*, pci, prelude::*};
+use kernel::{device, devres::Devres, error::code::*, fmt, pci, prelude::*};
 
 use crate::driver::Bar0;
 use crate::firmware::{Firmware, FIRMWARE_VERSION};
 use crate::regs;
 use crate::util;
-use core::fmt;
 
 macro_rules! define_chipset {
     ({ $($variant:ident = $value:expr),* $(,)* }) =>
diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core/regs/macros.rs
index 6851af8b5885..759773a19480 100644
--- a/drivers/gpu/nova-core/regs/macros.rs
+++ b/drivers/gpu/nova-core/regs/macros.rs
@@ -106,10 +106,10 @@ macro_rules! register {
 
         // TODO: display the raw hex value, then the value of all the fields. This requires
         // matching the fields, which will complexify the syntax considerably...
-        impl ::core::fmt::Debug for $name {
-            fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+        impl ::kernel::fmt::Debug for $name {
+            fn fmt(&self, f: &mut ::kernel::fmt::Formatter<'_>) -> ::kernel::fmt::Result {
                 f.debug_tuple(stringify!($name))
-                    .field(&format_args!("0x{0:x}", &self.0))
+                    .field(&::kernel::prelude::fmt!("0x{0:x}", &self.0))
                     .finish()
             }
         }

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/8] rust: alloc: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 1/8] gpu: nova-core: " Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 3/8] rust: block: " Tamir Duberstein
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/alloc/kbox.rs        | 2 +-
 rust/kernel/alloc/kvec.rs        | 2 +-
 rust/kernel/alloc/kvec/errors.rs | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs
index 856d05aa60f1..563187d09a8e 100644
--- a/rust/kernel/alloc/kbox.rs
+++ b/rust/kernel/alloc/kbox.rs
@@ -7,7 +7,6 @@
 use super::{AllocError, Allocator, Flags};
 use core::alloc::Layout;
 use core::borrow::{Borrow, BorrowMut};
-use core::fmt;
 use core::marker::PhantomData;
 use core::mem::ManuallyDrop;
 use core::mem::MaybeUninit;
@@ -17,6 +16,7 @@
 use core::result::Result;
 
 use crate::ffi::c_void;
+use crate::fmt;
 use crate::init::InPlaceInit;
 use crate::types::ForeignOwnable;
 use pin_init::{InPlaceWrite, Init, PinInit, ZeroableOption};
diff --git a/rust/kernel/alloc/kvec.rs b/rust/kernel/alloc/kvec.rs
index 3c72e0bdddb8..4a1b2c26209a 100644
--- a/rust/kernel/alloc/kvec.rs
+++ b/rust/kernel/alloc/kvec.rs
@@ -7,9 +7,9 @@
     layout::ArrayLayout,
     AllocError, Allocator, Box, Flags,
 };
+use crate::fmt;
 use core::{
     borrow::{Borrow, BorrowMut},
-    fmt,
     marker::PhantomData,
     mem::{ManuallyDrop, MaybeUninit},
     ops::Deref,
diff --git a/rust/kernel/alloc/kvec/errors.rs b/rust/kernel/alloc/kvec/errors.rs
index 348b8d27e102..21a920a4b09b 100644
--- a/rust/kernel/alloc/kvec/errors.rs
+++ b/rust/kernel/alloc/kvec/errors.rs
@@ -2,7 +2,7 @@
 
 //! Errors for the [`Vec`] type.
 
-use core::fmt::{self, Debug, Formatter};
+use kernel::fmt::{self, Debug, Formatter};
 use kernel::prelude::*;
 
 /// Error type for [`Vec::push_within_capacity`].

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 3/8] rust: block: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 1/8] gpu: nova-core: " Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 2/8] rust: alloc: " Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-08-08  9:43   ` Andreas Hindborg
  2025-07-19 22:41 ` [PATCH v2 4/8] rust: device: " Tamir Duberstein
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Custom.20formatting/with/516476467
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 drivers/block/rnull.rs             | 2 +-
 rust/kernel/block/mq.rs            | 2 +-
 rust/kernel/block/mq/gen_disk.rs   | 2 +-
 rust/kernel/block/mq/raw_writer.rs | 3 +--
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/block/rnull.rs b/drivers/block/rnull.rs
index d07e76ae2c13..6366da12c5a5 100644
--- a/drivers/block/rnull.rs
+++ b/drivers/block/rnull.rs
@@ -51,7 +51,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
                 .logical_block_size(4096)?
                 .physical_block_size(4096)?
                 .rotational(false)
-                .build(format_args!("rnullb{}", 0), tagset)
+                .build(fmt!("rnullb{}", 0), tagset)
         })();
 
         try_pin_init!(Self {
diff --git a/rust/kernel/block/mq.rs b/rust/kernel/block/mq.rs
index 831445d37181..61ea35bba7d5 100644
--- a/rust/kernel/block/mq.rs
+++ b/rust/kernel/block/mq.rs
@@ -82,7 +82,7 @@
 //!     Arc::pin_init(TagSet::new(1, 256, 1), flags::GFP_KERNEL)?;
 //! let mut disk = gen_disk::GenDiskBuilder::new()
 //!     .capacity_sectors(4096)
-//!     .build(format_args!("myblk"), tagset)?;
+//!     .build(fmt!("myblk"), tagset)?;
 //!
 //! # Ok::<(), kernel::error::Error>(())
 //! ```
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index cd54cd64ea88..494c95623b97 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -6,9 +6,9 @@
 //! C header: [`include/linux/blk_mq.h`](srctree/include/linux/blk_mq.h)
 
 use crate::block::mq::{raw_writer::RawWriter, Operations, TagSet};
+use crate::fmt::{self, Write};
 use crate::{bindings, error::from_err_ptr, error::Result, sync::Arc};
 use crate::{error, static_lock_class};
-use core::fmt::{self, Write};
 
 /// A builder for [`GenDisk`].
 ///
diff --git a/rust/kernel/block/mq/raw_writer.rs b/rust/kernel/block/mq/raw_writer.rs
index 7e2159e4f6a6..d311e24e2595 100644
--- a/rust/kernel/block/mq/raw_writer.rs
+++ b/rust/kernel/block/mq/raw_writer.rs
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
-use core::fmt::{self, Write};
-
 use crate::error::Result;
+use crate::fmt::{self, Write};
 use crate::prelude::EINVAL;
 
 /// A mutable reference to a byte buffer where a string can be written into.

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 4/8] rust: device: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
                   ` (2 preceding siblings ...)
  2025-07-19 22:41 ` [PATCH v2 3/8] rust: block: " Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 5/8] rust: file: " Tamir Duberstein
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/device.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
index 5c946af3a4d5..9e9ecdb1beec 100644
--- a/rust/kernel/device.rs
+++ b/rust/kernel/device.rs
@@ -5,11 +5,11 @@
 //! C header: [`include/linux/device.h`](srctree/include/linux/device.h)
 
 use crate::{
-    bindings,
+    bindings, fmt,
     str::CStr,
     types::{ARef, Opaque},
 };
-use core::{fmt, marker::PhantomData, ptr};
+use core::{marker::PhantomData, ptr};
 
 #[cfg(CONFIG_PRINTK)]
 use crate::c_str;
@@ -345,7 +345,7 @@ macro_rules! impl_device_context_into_aref {
 macro_rules! dev_printk {
     ($method:ident, $dev:expr, $($f:tt)*) => {
         {
-            ($dev).$method(::core::format_args!($($f)*));
+            ($dev).$method($crate::prelude::fmt!($($f)*));
         }
     }
 }

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 5/8] rust: file: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
                   ` (3 preceding siblings ...)
  2025-07-19 22:41 ` [PATCH v2 4/8] rust: device: " Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-07-21 21:24   ` Miguel Ojeda
  2025-07-19 22:41 ` [PATCH v2 6/8] rust: kunit: " Tamir Duberstein
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/fs/file.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/fs/file.rs b/rust/kernel/fs/file.rs
index 35fd5db35c46..67a3654f0fd3 100644
--- a/rust/kernel/fs/file.rs
+++ b/rust/kernel/fs/file.rs
@@ -11,6 +11,7 @@
     bindings,
     cred::Credential,
     error::{code::*, Error, Result},
+    fmt,
     types::{ARef, AlwaysRefCounted, NotThreadSafe, Opaque},
 };
 use core::ptr;
@@ -460,8 +461,8 @@ fn from(_: BadFdError) -> Error {
     }
 }
 
-impl core::fmt::Debug for BadFdError {
-    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+impl fmt::Debug for BadFdError {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.pad("EBADF")
     }
 }

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 6/8] rust: kunit: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
                   ` (4 preceding siblings ...)
  2025-07-19 22:41 ` [PATCH v2 5/8] rust: file: " Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-07-19 22:41 ` [PATCH v2 7/8] rust: seq_file: " Tamir Duberstein
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/kunit.rs        | 8 ++++----
 scripts/rustdoc_test_gen.rs | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs
index 099a61bbb8f4..42498cb93f33 100644
--- a/rust/kernel/kunit.rs
+++ b/rust/kernel/kunit.rs
@@ -6,8 +6,8 @@
 //!
 //! Reference: <https://docs.kernel.org/dev-tools/kunit/index.html>
 
+use crate::fmt;
 use crate::prelude::*;
-use core::fmt;
 
 #[cfg(CONFIG_PRINTK)]
 use crate::c_str;
@@ -74,14 +74,14 @@ macro_rules! kunit_assert {
                 // mistake (it is hidden to prevent that).
                 //
                 // This mimics KUnit's failed assertion format.
-                $crate::kunit::err(format_args!(
+                $crate::kunit::err($crate::prelude::fmt!(
                     "    # {}: ASSERTION FAILED at {FILE}:{LINE}\n",
                     $name
                 ));
-                $crate::kunit::err(format_args!(
+                $crate::kunit::err($crate::prelude::fmt!(
                     "    Expected {CONDITION} to be true, but is false\n"
                 ));
-                $crate::kunit::err(format_args!(
+                $crate::kunit::err($crate::prelude::fmt!(
                     "    Failure not reported to KUnit since this is a non-KUnit task\n"
                 ));
                 break 'out;
diff --git a/scripts/rustdoc_test_gen.rs b/scripts/rustdoc_test_gen.rs
index 1ca253594d38..507d36875196 100644
--- a/scripts/rustdoc_test_gen.rs
+++ b/scripts/rustdoc_test_gen.rs
@@ -201,7 +201,7 @@ macro_rules! assert_eq {{
     // This follows the syntax for declaring test metadata in the proposed KTAP v2 spec, which may
     // be used for the proposed KUnit test attributes API. Thus hopefully this will make migration
     // easier later on.
-    ::kernel::kunit::info(format_args!("    # {kunit_name}.location: {real_path}:{line}\n"));
+    ::kernel::kunit::info(fmt!("    # {kunit_name}.location: {real_path}:{line}\n"));
 
     /// The anchor where the test code body starts.
     #[allow(unused)]

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 7/8] rust: seq_file: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
                   ` (5 preceding siblings ...)
  2025-07-19 22:41 ` [PATCH v2 6/8] rust: kunit: " Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-07-21 21:25   ` Miguel Ojeda
  2025-07-19 22:41 ` [PATCH v2 8/8] rust: sync: " Tamir Duberstein
  2025-07-21 20:25 ` [PATCH v2 0/8] rust: " Miguel Ojeda
  8 siblings, 1 reply; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/seq_file.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/seq_file.rs b/rust/kernel/seq_file.rs
index 8f199b1a3bb1..59fbfc2473f8 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, types::NotThreadSafe, types::Opaque};
+use crate::{bindings, c_str, fmt, types::NotThreadSafe, types::Opaque};
 
 /// A utility for generating the contents of a seq file.
 #[repr(transparent)]
@@ -31,7 +31,7 @@ pub unsafe fn from_raw<'a>(ptr: *mut bindings::seq_file) -> &'a SeqFile {
 
     /// Used by the [`seq_print`] macro.
     #[inline]
-    pub fn call_printf(&self, args: core::fmt::Arguments<'_>) {
+    pub fn call_printf(&self, args: fmt::Arguments<'_>) {
         // SAFETY: Passing a void pointer to `Arguments` is valid for `%pA`.
         unsafe {
             bindings::seq_printf(
@@ -47,7 +47,7 @@ pub fn call_printf(&self, args: core::fmt::Arguments<'_>) {
 #[macro_export]
 macro_rules! seq_print {
     ($m:expr, $($arg:tt)+) => (
-        $m.call_printf(format_args!($($arg)+))
+        $m.call_printf($crate::prelude::fmt!($($arg)+))
     );
 }
 pub use seq_print;

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 8/8] rust: sync: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
                   ` (6 preceding siblings ...)
  2025-07-19 22:41 ` [PATCH v2 7/8] rust: seq_file: " Tamir Duberstein
@ 2025-07-19 22:41 ` Tamir Duberstein
  2025-07-21 20:25 ` [PATCH v2 0/8] rust: " Miguel Ojeda
  8 siblings, 0 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-19 22:41 UTC (permalink / raw)
  To: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
 rust/kernel/sync/arc.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
index 63a66761d0c7..4f3c1c2ff05e 100644
--- a/rust/kernel/sync/arc.rs
+++ b/rust/kernel/sync/arc.rs
@@ -20,6 +20,7 @@
     alloc::{AllocError, Flags, KBox},
     bindings,
     ffi::c_void,
+    fmt,
     init::InPlaceInit,
     try_init,
     types::{ForeignOwnable, Opaque},
@@ -27,7 +28,6 @@
 use core::{
     alloc::Layout,
     borrow::{Borrow, BorrowMut},
-    fmt,
     marker::PhantomData,
     mem::{ManuallyDrop, MaybeUninit},
     ops::{Deref, DerefMut},

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
                   ` (7 preceding siblings ...)
  2025-07-19 22:41 ` [PATCH v2 8/8] rust: sync: " Tamir Duberstein
@ 2025-07-21 20:25 ` Miguel Ojeda
  2025-07-21 20:33   ` Tamir Duberstein
  8 siblings, 1 reply; 14+ messages in thread
From: Miguel Ojeda @ 2025-07-21 20:25 UTC (permalink / raw)
  To: Tamir Duberstein
  Cc: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki, nouveau,
	dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev

On Sun, Jul 20, 2025 at 12:42 AM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Subsystem maintainers: I would appreciate your `Acked-by`s so that this
> can be taken through Miguel's tree (where the other series must go).

Same here as in step 2b/5, i.e. Danilo's Acked-by was picked up for
things he didn't Acked-by.

I imagine it was automatically done by `b4`, but that is why we need
to be careful about automatically applying tags. I am mentioning this
mainly to confirm I am not confused and to avoid forgetting about it,
and also I hope it helps if you eventually apply patches yourself,
e.g. if you eventually take care of a branch yourself.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}`
  2025-07-21 20:25 ` [PATCH v2 0/8] rust: " Miguel Ojeda
@ 2025-07-21 20:33   ` Tamir Duberstein
  0 siblings, 0 replies; 14+ messages in thread
From: Tamir Duberstein @ 2025-07-21 20:33 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki, nouveau,
	dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev

On Mon, Jul 21, 2025 at 4:25 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Sun, Jul 20, 2025 at 12:42 AM Tamir Duberstein <tamird@gmail.com> wrote:
> >
> > Subsystem maintainers: I would appreciate your `Acked-by`s so that this
> > can be taken through Miguel's tree (where the other series must go).
>
> Same here as in step 2b/5, i.e. Danilo's Acked-by was picked up for
> things he didn't Acked-by.

Yes, you are right.

>
> I imagine it was automatically done by `b4`, but that is why we need
> to be careful about automatically applying tags. I am mentioning this
> mainly to confirm I am not confused and to avoid forgetting about it,
> and also I hope it helps if you eventually apply patches yourself,
> e.g. if you eventually take care of a branch yourself.

You're not confused, and I appreciate you calling it out. I'll look
out for this kind of thing in the future.

Thanks Miguel.
Tamir

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 5/8] rust: file: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 ` [PATCH v2 5/8] rust: file: " Tamir Duberstein
@ 2025-07-21 21:24   ` Miguel Ojeda
  0 siblings, 0 replies; 14+ messages in thread
From: Miguel Ojeda @ 2025-07-21 21:24 UTC (permalink / raw)
  To: Tamir Duberstein, Christian Brauner
  Cc: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki, nouveau,
	dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Alexander Viro, Jan Kara,
	linux-fsdevel

On Sun, Jul 20, 2025 at 12:42 AM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Reduce coupling to implementation details of the formatting machinery by
> avoiding direct use for `core`'s formatting traits and macros.
>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Benno Lossin <lossin@kernel.org>
> Acked-by: Danilo Krummrich <dakr@kernel.org>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>

VFS should be Cc'd on this one, so doing so here.

Christian: I will eventually apply this series, so please let me know
if you are against this one (Acked-by's appreciated, of course),
thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 7/8] rust: seq_file: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 ` [PATCH v2 7/8] rust: seq_file: " Tamir Duberstein
@ 2025-07-21 21:25   ` Miguel Ojeda
  0 siblings, 0 replies; 14+ messages in thread
From: Miguel Ojeda @ 2025-07-21 21:25 UTC (permalink / raw)
  To: Tamir Duberstein, Christian Brauner
  Cc: Danilo Krummrich, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki, nouveau,
	dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Alexander Viro, Jan Kara,
	linux-fsdevel

On Sun, Jul 20, 2025 at 12:42 AM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Reduce coupling to implementation details of the formatting machinery by
> avoiding direct use for `core`'s formatting traits and macros.
>
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Benno Lossin <lossin@kernel.org>
> Acked-by: Danilo Krummrich <dakr@kernel.org>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>

VFS should be Cc'd on this one, so doing so here.

Christian: I will eventually apply this series, so please let me know
if you are against this one (Acked-by's appreciated, of course),
thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 3/8] rust: block: use `kernel::{fmt,prelude::fmt!}`
  2025-07-19 22:41 ` [PATCH v2 3/8] rust: block: " Tamir Duberstein
@ 2025-08-08  9:43   ` Andreas Hindborg
  0 siblings, 0 replies; 14+ messages in thread
From: Andreas Hindborg @ 2025-08-08  9:43 UTC (permalink / raw)
  To: Tamir Duberstein, Danilo Krummrich, David Airlie, Simona Vetter,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Jens Axboe, Greg Kroah-Hartman, Rafael J. Wysocki,
	Brendan Higgins, David Gow, Rae Moar, Lorenzo Stoakes,
	Vlastimil Babka, Liam R. Howlett, Uladzislau Rezki
  Cc: nouveau, dri-devel, linux-kernel, rust-for-linux, linux-block,
	linux-kselftest, kunit-dev, Tamir Duberstein

"Tamir Duberstein" <tamird@gmail.com> writes:

> Reduce coupling to implementation details of the formatting machinery by
> avoiding direct use for `core`'s formatting traits and macros.
>
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Custom.20formatting/with/516476467
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Benno Lossin <lossin@kernel.org>
> Acked-by: Danilo Krummrich <dakr@kernel.org>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>

Acked-by: Andreas Hindborg <a.hindborg@kernel.org>


Best regards,
Andreas Hindborg



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-08-08  9:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-19 22:41 [PATCH v2 0/8] rust: use `kernel::{fmt,prelude::fmt!}` Tamir Duberstein
2025-07-19 22:41 ` [PATCH v2 1/8] gpu: nova-core: " Tamir Duberstein
2025-07-19 22:41 ` [PATCH v2 2/8] rust: alloc: " Tamir Duberstein
2025-07-19 22:41 ` [PATCH v2 3/8] rust: block: " Tamir Duberstein
2025-08-08  9:43   ` Andreas Hindborg
2025-07-19 22:41 ` [PATCH v2 4/8] rust: device: " Tamir Duberstein
2025-07-19 22:41 ` [PATCH v2 5/8] rust: file: " Tamir Duberstein
2025-07-21 21:24   ` Miguel Ojeda
2025-07-19 22:41 ` [PATCH v2 6/8] rust: kunit: " Tamir Duberstein
2025-07-19 22:41 ` [PATCH v2 7/8] rust: seq_file: " Tamir Duberstein
2025-07-21 21:25   ` Miguel Ojeda
2025-07-19 22:41 ` [PATCH v2 8/8] rust: sync: " Tamir Duberstein
2025-07-21 20:25 ` [PATCH v2 0/8] rust: " Miguel Ojeda
2025-07-21 20:33   ` Tamir Duberstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).