mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
Kernel/ScatterGatherList: Return ErrorOr from try_create
This removes the TODO from the try_create API to return ErrorOr. This is also a preparation patch to move the init code in the constructor that can fail to this try_create function.
This commit is contained in:
parent
4617c05a08
commit
489e268b96
3 changed files with 5 additions and 9 deletions
|
@ -8,14 +8,10 @@
|
||||||
|
|
||||||
namespace Kernel::Memory {
|
namespace Kernel::Memory {
|
||||||
|
|
||||||
LockRefPtr<ScatterGatherList> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size)
|
ErrorOr<LockRefPtr<ScatterGatherList>> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size)
|
||||||
{
|
{
|
||||||
auto maybe_vm_object = AnonymousVMObject::try_create_with_physical_pages(allocated_pages);
|
auto vm_object = TRY(AnonymousVMObject::try_create_with_physical_pages(allocated_pages));
|
||||||
if (maybe_vm_object.is_error()) {
|
return adopt_lock_ref_if_nonnull(new (nothrow) ScatterGatherList(vm_object, request, device_block_size));
|
||||||
// FIXME: Would be nice to be able to return a ErrorOr here.
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return adopt_lock_ref_if_nonnull(new (nothrow) ScatterGatherList(maybe_vm_object.release_value(), request, device_block_size));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScatterGatherList::ScatterGatherList(NonnullLockRefPtr<AnonymousVMObject> vm_object, AsyncBlockDeviceRequest& request, size_t device_block_size)
|
ScatterGatherList::ScatterGatherList(NonnullLockRefPtr<AnonymousVMObject> vm_object, AsyncBlockDeviceRequest& request, size_t device_block_size)
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Kernel::Memory {
|
||||||
|
|
||||||
class ScatterGatherList final : public AtomicRefCounted<ScatterGatherList> {
|
class ScatterGatherList final : public AtomicRefCounted<ScatterGatherList> {
|
||||||
public:
|
public:
|
||||||
static LockRefPtr<ScatterGatherList> try_create(AsyncBlockDeviceRequest&, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size);
|
static ErrorOr<LockRefPtr<ScatterGatherList>> try_create(AsyncBlockDeviceRequest&, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size);
|
||||||
VMObject const& vmobject() const { return m_vm_object; }
|
VMObject const& vmobject() const { return m_vm_object; }
|
||||||
VirtualAddress dma_region() const { return m_dma_region->vaddr(); }
|
VirtualAddress dma_region() const { return m_dma_region->vaddr(); }
|
||||||
size_t scatters_count() const { return m_vm_object->physical_pages().size(); }
|
size_t scatters_count() const { return m_vm_object->physical_pages().size(); }
|
||||||
|
|
|
@ -429,7 +429,7 @@ Optional<AsyncDeviceRequest::RequestResult> AHCIPort::prepare_and_set_scatter_li
|
||||||
allocated_dma_regions.append(m_dma_buffers.at(index));
|
allocated_dma_regions.append(m_dma_buffers.at(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size());
|
m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size()).release_value_but_fixme_should_propagate_errors();
|
||||||
if (!m_current_scatter_list)
|
if (!m_current_scatter_list)
|
||||||
return AsyncDeviceRequest::Failure;
|
return AsyncDeviceRequest::Failure;
|
||||||
if (request.request_type() == AsyncBlockDeviceRequest::Write) {
|
if (request.request_type() == AsyncBlockDeviceRequest::Write) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue