From: Andreas Hindborg Date: Tue, 3 Mar 2026 20:17:00 +0000 (-0800) Subject: rust: sync: atomic: Update documentation for `fetch_add()` X-Git-Tag: v7.1-rc1~199^2~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0b864375d93d1509821def9c4b15f845d314a5d2;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/rust/kernel/sync/atomic.rs b/rust/kernel/sync/atomic.rs index 545a8d37ba787..9cd009d57e352 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