Kernel/HID: Don't use *LockRefPtrs in the I8042Controller code

This commit is contained in:
Liav A 2023-04-15 09:22:31 +03:00 committed by Andreas Kling
parent 747efc5265
commit 32557be930
Notes: sideshowbarker 2024-07-17 07:19:27 +09:00
4 changed files with 8 additions and 6 deletions

View file

@ -17,9 +17,9 @@
namespace Kernel { namespace Kernel {
UNMAP_AFTER_INIT NonnullLockRefPtr<I8042Controller> I8042Controller::initialize() UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<I8042Controller>> I8042Controller::create()
{ {
return adopt_lock_ref(*new I8042Controller()); return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) I8042Controller()));
} }
UNMAP_AFTER_INIT I8042Controller::I8042Controller() UNMAP_AFTER_INIT I8042Controller::I8042Controller()

View file

@ -90,7 +90,7 @@ protected:
{ {
} }
NonnullLockRefPtr<I8042Controller> m_i8042_controller; NonnullRefPtr<I8042Controller> const m_i8042_controller;
}; };
class PS2KeyboardDevice; class PS2KeyboardDevice;
@ -101,7 +101,7 @@ class I8042Controller final : public HIDController {
friend class PS2MouseDevice; friend class PS2MouseDevice;
public: public:
static NonnullLockRefPtr<I8042Controller> initialize(); static ErrorOr<NonnullRefPtr<I8042Controller>> create();
ErrorOr<void> detect_devices(); ErrorOr<void> detect_devices();

View file

@ -8,6 +8,8 @@
#include <AK/AtomicRefCounted.h> #include <AK/AtomicRefCounted.h>
#include <AK/IntrusiveList.h> #include <AK/IntrusiveList.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefPtr.h>
namespace Kernel { namespace Kernel {
@ -22,7 +24,7 @@ protected:
HIDController() = default; HIDController() = default;
private: private:
IntrusiveListNode<HIDController, NonnullLockRefPtr<HIDController>> m_list_node; IntrusiveListNode<HIDController, NonnullRefPtr<HIDController>> m_list_node;
}; };
} }

View file

@ -123,7 +123,7 @@ UNMAP_AFTER_INIT ErrorOr<void> HIDManagement::enumerate()
// set to emulate PS/2, we should not initialize the PS/2 controller. // set to emulate PS/2, we should not initialize the PS/2 controller.
#if ARCH(X86_64) #if ARCH(X86_64)
auto has_i8042_controller = false; auto has_i8042_controller = false;
auto i8042_controller = I8042Controller::initialize(); auto i8042_controller = TRY(I8042Controller::create());
switch (kernel_command_line().i8042_presence_mode()) { switch (kernel_command_line().i8042_presence_mode()) {
case I8042PresenceMode::Automatic: { case I8042PresenceMode::Automatic: {
// Note: If ACPI is disabled or doesn't indicate that we have an i8042, we // Note: If ACPI is disabled or doesn't indicate that we have an i8042, we