diff options
author | Liav A <liavalb@gmail.com> | 2021-09-07 07:29:11 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-08 10:27:02 +0200 |
commit | bde3c7301e89bade65231a2f3d2a96eaa1da1e91 (patch) | |
tree | 986463c4e5424ea452fea6bf3bbd010ab77f3bc3 /Kernel/Time | |
parent | 43b17f27a31f160eb2c92ed51bcc78b1efd93042 (diff) | |
download | serenity-bde3c7301e89bade65231a2f3d2a96eaa1da1e91.zip |
Kernel/ACPI: Return Optional container after table search
This is a better pattern than returning a PhysicalAddress with a zero
value, so the code is more understandable now.
Diffstat (limited to 'Kernel/Time')
-rw-r--r-- | Kernel/Time/HPET.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp index 7014033e83..9b94806ecc 100644 --- a/Kernel/Time/HPET.cpp +++ b/Kernel/Time/HPET.cpp @@ -119,12 +119,12 @@ UNMAP_AFTER_INIT bool HPET::test_and_initialize() { VERIFY(!HPET::initialized()); hpet_initialized = true; - auto hpet = ACPI::Parser::the()->find_table("HPET"); - if (hpet.is_null()) + auto hpet_table = ACPI::Parser::the()->find_table("HPET"); + if (!hpet_table.has_value()) return false; - dmesgln("HPET @ {}", hpet); + dmesgln("HPET @ {}", hpet_table.value()); - auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet); + auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet_table.value()); // Note: HPET is only usable from System Memory VERIFY(sdt->event_timer_block.address_space == (u8)ACPI::GenericAddressStructure::AddressSpace::SystemMemory); @@ -135,17 +135,17 @@ UNMAP_AFTER_INIT bool HPET::test_and_initialize() return false; } } - new HPET(PhysicalAddress(hpet)); + new HPET(PhysicalAddress(hpet_table.value())); return true; } UNMAP_AFTER_INIT bool HPET::check_for_exisiting_periodic_timers() { - auto hpet = ACPI::Parser::the()->find_table("HPET"); - if (hpet.is_null()) + auto hpet_table = ACPI::Parser::the()->find_table("HPET"); + if (!hpet_table.has_value()) return false; - auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet); + auto sdt = Memory::map_typed<ACPI::Structures::HPET>(hpet_table.value()); VERIFY(sdt->event_timer_block.address_space == 0); auto registers = Memory::map_typed<HPETRegistersBlock>(PhysicalAddress(sdt->event_timer_block.address)); |