From 0fd2066ac3441f16701aca2e5c7f8aea7d32af9d Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Tue, 25 Nov 2025 17:08:55 +0800 Subject: [PATCH] Fix potential atomic mode breaks --- kernel/comps/input/src/lib.rs | 6 +++--- kernel/src/device/evdev/mod.rs | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/comps/input/src/lib.rs b/kernel/comps/input/src/lib.rs index ae9af3713..3a614cda1 100644 --- a/kernel/comps/input/src/lib.rs +++ b/kernel/comps/input/src/lib.rs @@ -44,7 +44,7 @@ pub mod input_handler; use alloc::{sync::Arc, vec::Vec}; use component::{init_component, ComponentInitError}; -use ostd::sync::SpinLock; +use ostd::sync::Mutex; use spin::Once; use self::input_core::InputCore; @@ -117,13 +117,13 @@ fn component_init() -> Result<(), ComponentInitError> { #[derive(Debug)] struct Component { - input_core: SpinLock, + input_core: Mutex, } impl Component { pub fn init() -> Result { Ok(Self { - input_core: SpinLock::new(InputCore::new()), + input_core: Mutex::new(InputCore::new()), }) } } diff --git a/kernel/src/device/evdev/mod.rs b/kernel/src/device/evdev/mod.rs index 48983d330..5eb55c9b4 100644 --- a/kernel/src/device/evdev/mod.rs +++ b/kernel/src/device/evdev/mod.rs @@ -40,8 +40,7 @@ const EVDEV_MAJOR_ID: u16 = 13; static EVDEV_MINOR_COUNTER: AtomicU32 = AtomicU32::new(0); /// Global registry of evdev devices. -static EVDEV_DEVICES: SpinLock>> = - SpinLock::new(BTreeMap::new()); +static EVDEV_DEVICES: Mutex>> = Mutex::new(BTreeMap::new()); pub struct EvdevDevice { /// Input device associated with this evdev.