rust_binder: Switch to kernel::sync atomic primitives

Convert uses of AtomicBool, AtomicUsize, and AtomicU32.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Acked-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251230093718.1852322-4-fujita.tomonori@gmail.com
This commit is contained in:
FUJITA Tomonori
2025-12-30 18:37:18 +09:00
committed by Boqun Feng
parent 323e4bfcbe
commit 7f4c8b4dcd
4 changed files with 32 additions and 36 deletions

View File

@@ -15,6 +15,7 @@ use kernel::{
security,
seq_file::SeqFile,
seq_print,
sync::atomic::{ordering::Relaxed, Atomic},
sync::poll::{PollCondVar, PollTable},
sync::{Arc, SpinLock},
task::Task,
@@ -34,10 +35,7 @@ use crate::{
BinderReturnWriter, DArc, DLArc, DTRWrap, DeliverCode, DeliverToRead,
};
use core::{
mem::size_of,
sync::atomic::{AtomicU32, Ordering},
};
use core::mem::size_of;
/// Stores the layout of the scatter-gather entries. This is used during the `translate_objects`
/// call and is discarded when it returns.
@@ -273,8 +271,8 @@ const LOOPER_POLL: u32 = 0x40;
impl InnerThread {
fn new() -> Result<Self> {
fn next_err_id() -> u32 {
static EE_ID: AtomicU32 = AtomicU32::new(0);
EE_ID.fetch_add(1, Ordering::Relaxed)
static EE_ID: Atomic<u32> = Atomic::new(0);
EE_ID.fetch_add(1, Relaxed)
}
Ok(Self {
@@ -1537,7 +1535,7 @@ impl Thread {
#[pin_data]
struct ThreadError {
error_code: AtomicU32,
error_code: Atomic<u32>,
#[pin]
links_track: AtomicTracker,
}
@@ -1545,18 +1543,18 @@ struct ThreadError {
impl ThreadError {
fn try_new() -> Result<DArc<Self>> {
DTRWrap::arc_pin_init(pin_init!(Self {
error_code: AtomicU32::new(BR_OK),
error_code: Atomic::new(BR_OK),
links_track <- AtomicTracker::new(),
}))
.map(ListArc::into_arc)
}
fn set_error_code(&self, code: u32) {
self.error_code.store(code, Ordering::Relaxed);
self.error_code.store(code, Relaxed);
}
fn is_unused(&self) -> bool {
self.error_code.load(Ordering::Relaxed) == BR_OK
self.error_code.load(Relaxed) == BR_OK
}
}
@@ -1566,8 +1564,8 @@ impl DeliverToRead for ThreadError {
_thread: &Thread,
writer: &mut BinderReturnWriter<'_>,
) -> Result<bool> {
let code = self.error_code.load(Ordering::Relaxed);
self.error_code.store(BR_OK, Ordering::Relaxed);
let code = self.error_code.load(Relaxed);
self.error_code.store(BR_OK, Relaxed);
writer.write_code(code)?;
Ok(true)
}
@@ -1583,7 +1581,7 @@ impl DeliverToRead for ThreadError {
m,
"{}transaction error: {}\n",
prefix,
self.error_code.load(Ordering::Relaxed)
self.error_code.load(Relaxed)
);
Ok(())
}