summaryrefslogtreecommitdiff
path: root/rust/kernel
diff options
context:
space:
mode:
authorBoqun Feng <boqun.feng@gmail.com>2025-10-21 23:53:23 -0400
committerBoqun Feng <boqun.feng@gmail.com>2025-11-12 08:56:41 -0800
commit013f912eb5fa7c06b3648ca630acfc4ff26456fa (patch)
tree3a8dcfa278e40c1d1243c3237ca6628687b31f0d /rust/kernel
parent14e9a18b07ec463a85094cc8942788336164319f (diff)
rust: sync: atomic: Implement Debug for Atomic<Debug>
If `Atomic<T>` is `Debug` then it's a `debugfs::Writer`, therefore make it so since 1) debugfs needs to support `Atomic<T>` and 2) it's rather trivial to implement `Debug` for `Atomic<Debug>`. Tested-by: David Gow <davidgow@google.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20251022035324.70785-3-boqun.feng@gmail.com
Diffstat (limited to 'rust/kernel')
-rw-r--r--rust/kernel/sync/atomic.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/rust/kernel/sync/atomic.rs b/rust/kernel/sync/atomic.rs
index 0bc6e7b04d67..3afc376be42d 100644
--- a/rust/kernel/sync/atomic.rs
+++ b/rust/kernel/sync/atomic.rs
@@ -307,6 +307,15 @@ where
}
}
+impl<T: AtomicType + core::fmt::Debug> core::fmt::Debug for Atomic<T>
+where
+ T::Repr: AtomicBasicOps,
+{
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ core::fmt::Debug::fmt(&self.load(Relaxed), f)
+ }
+}
+
impl<T: AtomicType> Atomic<T>
where
T::Repr: AtomicExchangeOps,