Skip to content

Commit 6b1b232

Browse files
charmitroojeda
authored andcommitted
rust: sync: CondVar rename "wait_list" to "wait_queue_head"
Fields named "wait_list" usually are of type "struct list_head". To avoid confusion and because it is of type "Opaque<bindings::wait_queue_head>" we are renaming "wait_list" to "wait_queue_head". Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Link: https://lore.kernel.org/r/20240105012930.1426214-1-charmitro@posteo.net Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent c5fed8c commit 6b1b232

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

rust/kernel/sync/condvar.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ macro_rules! new_condvar {
7373
#[pin_data]
7474
pub struct CondVar {
7575
#[pin]
76-
pub(crate) wait_list: Opaque<bindings::wait_queue_head>,
76+
pub(crate) wait_queue_head: Opaque<bindings::wait_queue_head>,
7777

7878
/// A condvar needs to be pinned because it contains a [`struct list_head`] that is
7979
/// self-referential, so it cannot be safely moved once it is initialised.
@@ -96,7 +96,7 @@ impl CondVar {
9696
_pin: PhantomPinned,
9797
// SAFETY: `slot` is valid while the closure is called and both `name` and `key` have
9898
// static lifetimes so they live indefinitely.
99-
wait_list <- Opaque::ffi_init(|slot| unsafe {
99+
wait_queue_head <- Opaque::ffi_init(|slot| unsafe {
100100
bindings::__init_waitqueue_head(slot, name.as_char_ptr(), key.as_ptr())
101101
}),
102102
})
@@ -108,16 +108,20 @@ impl CondVar {
108108
// SAFETY: `wait` points to valid memory.
109109
unsafe { bindings::init_wait(wait.get()) };
110110

111-
// SAFETY: Both `wait` and `wait_list` point to valid memory.
111+
// SAFETY: Both `wait` and `wait_queue_head` point to valid memory.
112112
unsafe {
113-
bindings::prepare_to_wait_exclusive(self.wait_list.get(), wait.get(), wait_state as _)
113+
bindings::prepare_to_wait_exclusive(
114+
self.wait_queue_head.get(),
115+
wait.get(),
116+
wait_state as _,
117+
)
114118
};
115119

116120
// SAFETY: No arguments, switches to another thread.
117121
guard.do_unlocked(|| unsafe { bindings::schedule() });
118122

119-
// SAFETY: Both `wait` and `wait_list` point to valid memory.
120-
unsafe { bindings::finish_wait(self.wait_list.get(), wait.get()) };
123+
// SAFETY: Both `wait` and `wait_queue_head` point to valid memory.
124+
unsafe { bindings::finish_wait(self.wait_queue_head.get(), wait.get()) };
121125
}
122126

123127
/// Releases the lock and waits for a notification in uninterruptible mode.
@@ -144,10 +148,10 @@ impl CondVar {
144148

145149
/// Calls the kernel function to notify the appropriate number of threads with the given flags.
146150
fn notify(&self, count: i32, flags: u32) {
147-
// SAFETY: `wait_list` points to valid memory.
151+
// SAFETY: `wait_queue_head` points to valid memory.
148152
unsafe {
149153
bindings::__wake_up(
150-
self.wait_list.get(),
154+
self.wait_queue_head.get(),
151155
bindings::TASK_NORMAL,
152156
count,
153157
flags as _,

0 commit comments

Comments
 (0)