Skip to content

Commit aa2df1d

Browse files
committed
rust: rros: change some 'CONFIG_RROS' to 'CONFIG_RROS_SPINLOCK'
1 parent d897f9a commit aa2df1d

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

rust/kernel/sync/lock.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub unsafe trait Backend {
7777
///
7878
/// Exposes one of the kernel locking primitives. Which one is exposed depends on the lock
7979
/// [`Backend`] specified as the generic parameter `B`.
80-
#[cfg(not(CONFIG_RROS))]
80+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
8181
#[pin_data]
8282
pub struct Lock<T: ?Sized, B: Backend> {
8383
/// The kernel lock object.
@@ -95,15 +95,15 @@ pub struct Lock<T: ?Sized, B: Backend> {
9595
}
9696

9797
// SAFETY: `Lock` can be transferred across thread boundaries iff the data it protects can.
98-
#[cfg(not(CONFIG_RROS))]
98+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
9999
unsafe impl<T: ?Sized + Send, B: Backend> Send for Lock<T, B> {}
100100

101101
// SAFETY: `Lock` serialises the interior mutability it provides, so it is `Sync` as long as the
102102
// data it protects is `Send`.
103-
#[cfg(not(CONFIG_RROS))]
103+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
104104
unsafe impl<T: ?Sized + Send, B: Backend> Sync for Lock<T, B> {}
105105

106-
#[cfg(not(CONFIG_RROS))]
106+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
107107
impl<T, B: Backend> Lock<T, B> {
108108
/// Constructs a new lock initialiser.
109109
#[allow(clippy::new_ret_no_self)]
@@ -120,7 +120,7 @@ impl<T, B: Backend> Lock<T, B> {
120120
}
121121
}
122122

123-
#[cfg(not(CONFIG_RROS))]
123+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
124124
impl<T: ?Sized, B: Backend> Lock<T, B> {
125125
/// Acquires the lock and gives the caller access to the data protected by it.
126126
pub fn lock(&self) -> Guard<'_, T, B> {
@@ -137,7 +137,7 @@ impl<T: ?Sized, B: Backend> Lock<T, B> {
137137
/// Allows mutual exclusion primitives that implement the [`Backend`] trait to automatically unlock
138138
/// when a guard goes out of scope. It also provides a safe and convenient way to access the data
139139
/// protected by the lock.
140-
#[cfg(not(CONFIG_RROS))]
140+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
141141
#[must_use = "the lock unlocks immediately when the guard is unused"]
142142
pub struct Guard<'a, T: ?Sized, B: Backend> {
143143
pub(crate) lock: &'a Lock<T, B>,
@@ -146,10 +146,10 @@ pub struct Guard<'a, T: ?Sized, B: Backend> {
146146
}
147147

148148
// SAFETY: `Guard` is sync when the data protected by the lock is also sync.
149-
#[cfg(not(CONFIG_RROS))]
149+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
150150
unsafe impl<T: Sync + ?Sized, B: Backend> Sync for Guard<'_, T, B> {}
151151

152-
#[cfg(not(CONFIG_RROS))]
152+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
153153
impl<T: ?Sized, B: Backend> Guard<'_, T, B> {
154154
pub(crate) fn do_unlocked(&mut self, cb: impl FnOnce()) {
155155
// SAFETY: The caller owns the lock, so it is safe to unlock it.
@@ -163,7 +163,7 @@ impl<T: ?Sized, B: Backend> Guard<'_, T, B> {
163163
}
164164
}
165165

166-
#[cfg(not(CONFIG_RROS))]
166+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
167167
impl<T: ?Sized, B: Backend> core::ops::Deref for Guard<'_, T, B> {
168168
type Target = T;
169169

@@ -173,23 +173,23 @@ impl<T: ?Sized, B: Backend> core::ops::Deref for Guard<'_, T, B> {
173173
}
174174
}
175175

176-
#[cfg(not(CONFIG_RROS))]
176+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
177177
impl<T: ?Sized, B: Backend> core::ops::DerefMut for Guard<'_, T, B> {
178178
fn deref_mut(&mut self) -> &mut Self::Target {
179179
// SAFETY: The caller owns the lock, so it is safe to deref the protected data.
180180
unsafe { &mut *self.lock.data.get() }
181181
}
182182
}
183183

184-
#[cfg(not(CONFIG_RROS))]
184+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
185185
impl<T: ?Sized, B: Backend> Drop for Guard<'_, T, B> {
186186
fn drop(&mut self) {
187187
// SAFETY: The caller owns the lock, so it is safe to unlock it.
188188
unsafe { B::unlock(self.lock.state.get(), &self.state) };
189189
}
190190
}
191191

192-
#[cfg(not(CONFIG_RROS))]
192+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
193193
impl<'a, T: ?Sized, B: Backend> Guard<'a, T, B> {
194194
/// Constructs a new immutable lock guard.
195195
///
@@ -247,7 +247,7 @@ pub trait NeedsLockClass {
247247
}
248248

249249
/// Reschedules the caller's task if needed.
250-
#[cfg(CONFIG_RROS)]
250+
#[cfg(CONFIG_RROS_SPINLOCK)]
251251
pub fn cond_resched() -> bool {
252252
// SAFETY: No arguments, reschedules `current` if needed.
253253
unsafe { rust_helper_cond_resched() != 0 }

rust/kernel/sync/lock/spinlock.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::str::CStr;
2323
///
2424
/// It uses the name if one is given, otherwise it generates one based on the file name and line
2525
/// number.
26-
#[cfg(not(CONFIG_RROS))]
26+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
2727
#[macro_export]
2828
macro_rules! new_spinlock {
2929
($inner:expr $(, $name:literal)? $(,)?) => {
@@ -97,7 +97,7 @@ macro_rules! new_spinlock {
9797
/// ```
9898
///
9999
/// [`spinlock_t`]: ../../../../include/linux/spinlock.h
100-
#[cfg(not(CONFIG_RROS))]
100+
#[cfg(not(CONFIG_RROS_SPINLOCK))]
101101
pub type SpinLock<T> = super::Lock<T, SpinLockBackend>;
102102

103103
/// A kernel `spinlock_t` lock backend.
@@ -176,7 +176,7 @@ macro_rules! spinlock_init {
176176
/// handlers (in which case it is ok for interrupts to be enabled).
177177
///
178178
/// [`spinlock_t`]: ../../../include/linux/spinlock.h
179-
#[cfg(CONFIG_RROS)]
179+
#[cfg(CONFIG_RROS_SPINLOCK)]
180180
pub struct SpinLock<T: ?Sized> {
181181
spin_lock: Opaque<bindings::spinlock>,
182182

@@ -188,15 +188,15 @@ pub struct SpinLock<T: ?Sized> {
188188
}
189189

190190
// SAFETY: `SpinLock` can be transferred across thread boundaries iff the data it protects can.
191-
#[cfg(CONFIG_RROS)]
191+
#[cfg(CONFIG_RROS_SPINLOCK)]
192192
unsafe impl<T: ?Sized + Send> Send for SpinLock<T> {}
193193

194194
// SAFETY: `SpinLock` serialises the interior mutability it provides, so it is `Sync` as long as the
195195
// data it protects is `Send`.
196-
#[cfg(CONFIG_RROS)]
196+
#[cfg(CONFIG_RROS_SPINLOCK)]
197197
unsafe impl<T: ?Sized + Send> Sync for SpinLock<T> {}
198198

199-
#[cfg(CONFIG_RROS)]
199+
#[cfg(CONFIG_RROS_SPINLOCK)]
200200
impl<T> SpinLock<T> {
201201
/// Constructs a new spinlock.
202202
///
@@ -212,7 +212,7 @@ impl<T> SpinLock<T> {
212212
}
213213
}
214214

215-
#[cfg(CONFIG_RROS)]
215+
#[cfg(CONFIG_RROS_SPINLOCK)]
216216
impl<T: ?Sized> SpinLock<T> {
217217
/// Locks the spinlock and gives the caller access to the data protected by it. Only one thread
218218
/// at a time is allowed to access the protected data.
@@ -277,15 +277,15 @@ impl<T: ?Sized> SpinLock<T> {
277277
}
278278
}
279279

280-
#[cfg(CONFIG_RROS)]
280+
#[cfg(CONFIG_RROS_SPINLOCK)]
281281
impl<T: ?Sized> NeedsLockClass for SpinLock<T> {
282282
unsafe fn init(self: Pin<&mut Self>, name: &'static CStr, key: *mut bindings::lock_class_key) {
283283
// SAFETY: The caller guarantees that `name` and `key` are initialised. So the pointers are valid.
284284
unsafe { rust_helper_spin_lock_init(self.spin_lock.get(), name.as_char_ptr(), key) };
285285
}
286286
}
287287

288-
#[cfg(CONFIG_RROS)]
288+
#[cfg(CONFIG_RROS_SPINLOCK)]
289289
impl<T: ?Sized> Lock for SpinLock<T> {
290290
type Inner = T;
291291

0 commit comments

Comments
 (0)