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().
This commit is contained in:
parent
489e268b96
commit
e067046474
Notes:
sideshowbarker
2024-07-17 03:25:24 +09:00
Author: https://github.com/Panky-codes Commit: https://github.com/SerenityOS/serenity/commit/e067046474 Pull-request: https://github.com/SerenityOS/serenity/pull/18898 Reviewed-by: https://github.com/BenWiederhake ✅ Reviewed-by: https://github.com/gmta ✅
2 changed files with 8 additions and 8 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue