1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

Kernel/USB: Tidy up UHCIDescriptorPool construction

- Use KResultOr<NonnullRefPtr<UHCIDescriptorPool<T>>
- Make the constructor private
- Use TRY() at call sites
This commit is contained in:
Andreas Kling 2021-09-06 00:51:35 +02:00
parent 91fe6b6552
commit cb71a73708
2 changed files with 20 additions and 28 deletions

View file

@ -130,11 +130,7 @@ KResult UHCIController::reset()
UNMAP_AFTER_INIT KResult UHCIController::create_structures()
{
m_queue_head_pool = UHCIDescriptorPool<QueueHead>::try_create("Queue Head Pool");
if (!m_queue_head_pool) {
dmesgln("UHCI: Failed to create Queue Head Pool!");
return ENOMEM;
}
m_queue_head_pool = TRY(UHCIDescriptorPool<QueueHead>::try_create("Queue Head Pool"sv));
// Create the Full Speed, Low Speed Control and Bulk Queue Heads
m_interrupt_transfer_queue = allocate_queue_head();
@ -146,11 +142,7 @@ UNMAP_AFTER_INIT KResult UHCIController::create_structures()
// Now the Transfer Descriptor pool
auto td_pool_vmobject = TRY(Memory::AnonymousVMObject::try_create_physically_contiguous_with_size(PAGE_SIZE));
m_transfer_descriptor_pool = UHCIDescriptorPool<TransferDescriptor>::try_create("Transfer Descriptor Pool");
if (!m_transfer_descriptor_pool) {
dmesgln("UHCI: Failed to create Transfer Descriptor Pool!");
return ENOMEM;
}
m_transfer_descriptor_pool = TRY(UHCIDescriptorPool<TransferDescriptor>::try_create("Transfer Descriptor Pool"sv));
m_isochronous_transfer_pool = MM.allocate_kernel_region_with_vmobject(move(td_pool_vmobject), PAGE_SIZE, "UHCI Isochronous Descriptor Pool", Memory::Region::Access::ReadWrite);
if (!m_isochronous_transfer_pool) {