diff --git a/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp b/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp index 648d60291c5..7c9c65721b1 100644 --- a/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp +++ b/Kernel/Arch/x86_64/ISABus/I8042Controller.cpp @@ -17,9 +17,9 @@ namespace Kernel { -UNMAP_AFTER_INIT NonnullLockRefPtr I8042Controller::initialize() +UNMAP_AFTER_INIT ErrorOr> I8042Controller::create() { - return adopt_lock_ref(*new I8042Controller()); + return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) I8042Controller())); } UNMAP_AFTER_INIT I8042Controller::I8042Controller() diff --git a/Kernel/Arch/x86_64/ISABus/I8042Controller.h b/Kernel/Arch/x86_64/ISABus/I8042Controller.h index 07905947e8d..bbb349a7782 100644 --- a/Kernel/Arch/x86_64/ISABus/I8042Controller.h +++ b/Kernel/Arch/x86_64/ISABus/I8042Controller.h @@ -90,7 +90,7 @@ protected: { } - NonnullLockRefPtr m_i8042_controller; + NonnullRefPtr const m_i8042_controller; }; class PS2KeyboardDevice; @@ -101,7 +101,7 @@ class I8042Controller final : public HIDController { friend class PS2MouseDevice; public: - static NonnullLockRefPtr initialize(); + static ErrorOr> create(); ErrorOr detect_devices(); diff --git a/Kernel/Devices/HID/Controller.h b/Kernel/Devices/HID/Controller.h index 1d8868297c2..be11bc056da 100644 --- a/Kernel/Devices/HID/Controller.h +++ b/Kernel/Devices/HID/Controller.h @@ -8,6 +8,8 @@ #include #include +#include +#include namespace Kernel { @@ -22,7 +24,7 @@ protected: HIDController() = default; private: - IntrusiveListNode> m_list_node; + IntrusiveListNode> m_list_node; }; } diff --git a/Kernel/Devices/HID/Management.cpp b/Kernel/Devices/HID/Management.cpp index df75a90d2c8..d6a19b3e507 100644 --- a/Kernel/Devices/HID/Management.cpp +++ b/Kernel/Devices/HID/Management.cpp @@ -123,7 +123,7 @@ UNMAP_AFTER_INIT ErrorOr HIDManagement::enumerate() // set to emulate PS/2, we should not initialize the PS/2 controller. #if ARCH(X86_64) auto has_i8042_controller = false; - auto i8042_controller = I8042Controller::initialize(); + auto i8042_controller = TRY(I8042Controller::create()); switch (kernel_command_line().i8042_presence_mode()) { case I8042PresenceMode::Automatic: { // Note: If ACPI is disabled or doesn't indicate that we have an i8042, we