diff options
author | Pankaj Raghav <dev@pankajraghav.com> | 2023-05-17 20:06:34 +0200 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-05-19 22:04:37 +0200 |
commit | e0670464748269274d529979388d153d8446cb65 (patch) | |
tree | cebbe0798f06e4e2422fa6d4305726c8eb4d1616 /Kernel | |
parent | 489e268b9669865a9b03efcf5d1393b2861a5aad (diff) | |
download | serenity-e0670464748269274d529979388d153d8446cb65.zip |
Kernel/ScatterGatherList: Move constructor init code to try_create
The constructor code of ScatterGatherList had code that can return
error. Move it to try_create for better error propagation.
This removes one TODO() and one
release_value_but_fixme_should_propagate_errors().
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Memory/ScatterGatherList.cpp | 12 | ||||
-rw-r--r-- | Kernel/Memory/ScatterGatherList.h | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Kernel/Memory/ScatterGatherList.cpp b/Kernel/Memory/ScatterGatherList.cpp index f49237c2d9..d4ff52d692 100644 --- a/Kernel/Memory/ScatterGatherList.cpp +++ b/Kernel/Memory/ScatterGatherList.cpp @@ -11,16 +11,16 @@ namespace Kernel::Memory { ErrorOr<LockRefPtr<ScatterGatherList>> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size) { auto vm_object = TRY(AnonymousVMObject::try_create_with_physical_pages(allocated_pages)); - return adopt_lock_ref_if_nonnull(new (nothrow) ScatterGatherList(vm_object, request, device_block_size)); + auto size = TRY(page_round_up((request.block_count() * device_block_size))); + auto region = TRY(MM.allocate_kernel_region_with_vmobject(vm_object, size, "AHCI Scattered DMA"sv, Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes)); + + return adopt_lock_ref_if_nonnull(new (nothrow) ScatterGatherList(vm_object, move(region))); } -ScatterGatherList::ScatterGatherList(NonnullLockRefPtr<AnonymousVMObject> vm_object, AsyncBlockDeviceRequest& request, size_t device_block_size) +ScatterGatherList::ScatterGatherList(NonnullLockRefPtr<AnonymousVMObject> vm_object, NonnullOwnPtr<Region> dma_region) : m_vm_object(move(vm_object)) + , m_dma_region(move(dma_region)) { - auto region_or_error = MM.allocate_kernel_region_with_vmobject(m_vm_object, page_round_up((request.block_count() * device_block_size)).release_value_but_fixme_should_propagate_errors(), "AHCI Scattered DMA"sv, Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes); - if (region_or_error.is_error()) - TODO(); - m_dma_region = region_or_error.release_value(); } } diff --git a/Kernel/Memory/ScatterGatherList.h b/Kernel/Memory/ScatterGatherList.h index d6920f025b..fb8fe49b7c 100644 --- a/Kernel/Memory/ScatterGatherList.h +++ b/Kernel/Memory/ScatterGatherList.h @@ -25,9 +25,9 @@ public: size_t scatters_count() const { return m_vm_object->physical_pages().size(); } private: - ScatterGatherList(NonnullLockRefPtr<AnonymousVMObject>, AsyncBlockDeviceRequest&, size_t device_block_size); + ScatterGatherList(NonnullLockRefPtr<AnonymousVMObject>, NonnullOwnPtr<Region> dma_region); NonnullLockRefPtr<AnonymousVMObject> m_vm_object; - OwnPtr<Region> m_dma_region; + NonnullOwnPtr<Region> m_dma_region; }; } |