From 013f912eb5fa7c06b3648ca630acfc4ff26456fa Mon Sep 17 00:00:00 2001 From: Boqun Feng Date: Tue, 21 Oct 2025 23:53:23 -0400 Subject: [PATCH] rust: sync: atomic: Implement Debug for Atomic If `Atomic` is `Debug` then it's a `debugfs::Writer`, therefore make it so since 1) debugfs needs to support `Atomic` and 2) it's rather trivial to implement `Debug` for `Atomic`. Tested-by: David Gow Acked-by: Greg Kroah-Hartman Signed-off-by: Boqun Feng Link: https://patch.msgid.link/20251022035324.70785-3-boqun.feng@gmail.com --- rust/kernel/sync/atomic.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rust/kernel/sync/atomic.rs b/rust/kernel/sync/atomic.rs index 0bc6e7b04d673..3afc376be42d9 100644 --- a/rust/kernel/sync/atomic.rs +++ b/rust/kernel/sync/atomic.rs @@ -307,6 +307,15 @@ where } } +impl core::fmt::Debug for Atomic +where + T::Repr: AtomicBasicOps, +{ + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + core::fmt::Debug::fmt(&self.load(Relaxed), f) + } +} + impl Atomic where T::Repr: AtomicExchangeOps, -- 2.47.3