[PATCH v2 2/2] rust: atomic: update documentation for `fetch_add`
From: Andreas Hindborg
Date: Thu Feb 19 2026 - 07:21:06 EST
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 <a.hindborg@xxxxxxxxxx>
---
rust/kernel/sync/atomic.rs | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/rust/kernel/sync/atomic.rs b/rust/kernel/sync/atomic.rs
index 83e03bb7ecd24..ce0ebd725d697 100644
--- a/rust/kernel/sync/atomic.rs
+++ b/rust/kernel/sync/atomic.rs
@@ -527,16 +527,15 @@ pub fn add<Rhs>(&self, v: Rhs, _: ordering::Relaxed)
/// 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!(42, x.fetch_add(12, Full));
+ /// assert_eq!(54, x.load(Relaxed));
///
- /// assert_eq!(54, { x.fetch_add(12, Full); x.load(Relaxed) } );
/// ```
#[inline(always)]
pub fn fetch_add<Rhs, Ordering: ordering::Ordering>(&self, v: Rhs, _: Ordering) -> T
--
2.51.2