From 0b864375d93d1509821def9c4b15f845d314a5d2 Mon Sep 17 00:00:00 2001 From: Andreas Hindborg Date: Tue, 3 Mar 2026 12:17:00 -0800 Subject: rust: sync: atomic: Update documentation for `fetch_add()` The documentation for `fetch_add()` does not indicate that the original value is returned by `fetch_add()`. Update the documentation so this is clear. Signed-off-by: Andreas Hindborg Signed-off-by: Boqun Feng Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Alice Ryhl Link: https://patch.msgid.link/20260220-atomic-sub-v3-2-e63cbed1d2aa@kernel.org Link: https://patch.msgid.link/20260303201701.12204-13-boqun@kernel.org --- rust/kernel/sync/atomic.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'rust/kernel/sync') diff --git a/rust/kernel/sync/atomic.rs b/rust/kernel/sync/atomic.rs index 545a8d37ba78..9cd009d57e35 100644 --- a/rust/kernel/sync/atomic.rs +++ b/rust/kernel/sync/atomic.rs @@ -545,16 +545,14 @@ where /// use kernel::sync::atomic::{Atomic, Acquire, Full, Relaxed}; /// /// let x = Atomic::new(42); - /// /// assert_eq!(42, x.load(Relaxed)); - /// - /// assert_eq!(54, { x.fetch_add(12, Acquire); x.load(Relaxed) }); + /// assert_eq!(42, x.fetch_add(12, Acquire)); + /// assert_eq!(54, x.load(Relaxed)); /// /// let x = Atomic::new(42); - /// /// assert_eq!(42, x.load(Relaxed)); - /// - /// assert_eq!(54, { x.fetch_add(12, Full); x.load(Relaxed) } ); + /// assert_eq!(42, x.fetch_add(12, Full)); + /// assert_eq!(54, x.load(Relaxed)); /// ``` #[inline(always)] pub fn fetch_add(&self, v: Rhs, _: Ordering) -> T -- cgit v1.2.3