From: Boqun Feng Date: Wed, 22 Oct 2025 03:53:23 +0000 (-0400) Subject: rust: sync: atomic: Implement Debug for Atomic X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=013f912eb5fa7c06b3648ca630acfc4ff26456fa;p=thirdparty%2Flinux.git 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 --- 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,