From 78f8821152e809bb0f20b4d1994de957acee01a3 Mon Sep 17 00:00:00 2001 From: Lorenz Steinert Date: Wed, 23 Feb 2022 22:14:09 +0100 Subject: [PATCH] Kernel: Propagate HIDManagement initialisation error to init Initialisation errors for HIDManagement are now returned to the init. In the init we assert by MUST if we get an error. --- Kernel/Devices/HID/HIDManagement.cpp | 5 ++--- Kernel/Devices/HID/HIDManagement.h | 2 +- Kernel/Devices/HID/PS2MouseDevice.cpp | 2 -- Kernel/init.cpp | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Kernel/Devices/HID/HIDManagement.cpp b/Kernel/Devices/HID/HIDManagement.cpp index 084f0befc6..51348c0e16 100644 --- a/Kernel/Devices/HID/HIDManagement.cpp +++ b/Kernel/Devices/HID/HIDManagement.cpp @@ -137,12 +137,11 @@ UNMAP_AFTER_INIT ErrorOr HIDManagement::enumerate() return {}; } -UNMAP_AFTER_INIT void HIDManagement::initialize() +UNMAP_AFTER_INIT ErrorOr HIDManagement::initialize() { VERIFY(!s_the.is_initialized()); s_the.ensure_instance(); - // FIXME: Propagate errors back to init to deal with them. - MUST(s_the->enumerate()); + return s_the->enumerate(); } HIDManagement& HIDManagement::the() diff --git a/Kernel/Devices/HID/HIDManagement.h b/Kernel/Devices/HID/HIDManagement.h index 691fe3d476..9588bf8e7e 100644 --- a/Kernel/Devices/HID/HIDManagement.h +++ b/Kernel/Devices/HID/HIDManagement.h @@ -35,7 +35,7 @@ class HIDManagement { public: HIDManagement(); - static void initialize(); + static ErrorOr initialize(); static HIDManagement& the(); ErrorOr enumerate(); diff --git a/Kernel/Devices/HID/PS2MouseDevice.cpp b/Kernel/Devices/HID/PS2MouseDevice.cpp index 5f6bcce8c0..13fc67035f 100644 --- a/Kernel/Devices/HID/PS2MouseDevice.cpp +++ b/Kernel/Devices/HID/PS2MouseDevice.cpp @@ -154,7 +154,6 @@ ErrorOr PS2MouseDevice::send_command(u8 command) if (response != I8042Response::Acknowledge) { dbgln("PS2MouseDevice: Command {} got {} but expected ack: {}", command, response, static_cast(I8042Response::Acknowledge)); - // FIXME: Is this the correct errno value for this? return Error::from_errno(EIO); } return response; @@ -165,7 +164,6 @@ ErrorOr PS2MouseDevice::send_command(u8 command, u8 data) u8 response = TRY(m_i8042_controller->send_command(instrument_type(), command, data)); if (response != I8042Response::Acknowledge) { dbgln("PS2MouseDevice: Command {} got {} but expected ack: {}", command, response, static_cast(I8042Response::Acknowledge)); - // FIXME: Is this the correct errno value for this? return Error::from_errno(EIO); } return response; diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 17e9dc4957..42d1b2a4db 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -326,7 +326,7 @@ void init_stage2(void*) (void)SerialDevice::must_create(3).leak_ref(); VMWareBackdoor::the(); // don't wait until first mouse packet - HIDManagement::initialize(); + MUST(HIDManagement::initialize()); GraphicsManagement::the().initialize(); ConsoleManagement::the().initialize();