Skip to content

Commit 013f912

Browse files
committed
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
1 parent 14e9a18 commit 013f912

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

rust/kernel/sync/atomic.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,15 @@ where
307307
}
308308
}
309309

310+
impl<T: AtomicType + core::fmt::Debug> core::fmt::Debug for Atomic<T>
311+
where
312+
T::Repr: AtomicBasicOps,
313+
{
314+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
315+
core::fmt::Debug::fmt(&self.load(Relaxed), f)
316+
}
317+
}
318+
310319
impl<T: AtomicType> Atomic<T>
311320
where
312321
T::Repr: AtomicExchangeOps,

0 commit comments

Comments
 (0)