Skip to content

Commit 3c18d74

Browse files
committed
change spinlock initialization in memory_rros.rs
1 parent aa2df1d commit 3c18d74

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

rust/kernel/memory_rros.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Rros Memory.
44
use crate::timekeeping::*;
55
use crate::{bindings, Result};
6-
use crate::{c_types, mm, prelude::*, premmpt, spinlock_init, sync::SpinLock, vmalloc};
6+
use crate::{c_types, mm, prelude::*, premmpt, new_spinlock, sync::SpinLock, vmalloc};
77
use core::{mem::size_of, ptr::addr_of_mut};
88

99
const PAGE_SIZE: u32 = 4096 as u32;
@@ -175,7 +175,7 @@ pub struct RrosHeap {
175175
pub buckets: [u32; RROS_HEAP_MAX_BUCKETS as usize],
176176
/// `lock` is an optional SpinLock used for ensuring thread-safety in the `RrosHeap`.
177177
/// It is initialized in the `init` method of the `RrosHeap` struct.
178-
pub lock: Option<SpinLock<i32>>,
178+
pub lock: Option<Pin<Box<SpinLock<i32>>>>,
179179
}
180180

181181
/// Implementation of the `RrosHeap` struct.
@@ -192,9 +192,7 @@ impl RrosHeap {
192192
return Err(crate::Error::EINVAL);
193193
}
194194

195-
let mut spinlock = unsafe { SpinLock::new(1) };
196-
let pinned = unsafe { Pin::new_unchecked(&mut spinlock) };
197-
spinlock_init!(pinned, "spinlock");
195+
let mut spinlock = Box::pin_init(new_spinlock!(1 as i32,"spinlock",)).unwrap();
198196
self.lock = Some(spinlock);
199197

200198
for i in self.buckets.iter_mut() {

0 commit comments

Comments
 (0)