mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
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
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue