diff options
Diffstat (limited to 'Kernel/Bus/USB/USBTransfer.cpp')
-rw-r--r-- | Kernel/Bus/USB/USBTransfer.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Kernel/Bus/USB/USBTransfer.cpp b/Kernel/Bus/USB/USBTransfer.cpp index e3a0e75d3b..ada524d4f0 100644 --- a/Kernel/Bus/USB/USBTransfer.cpp +++ b/Kernel/Bus/USB/USBTransfer.cpp @@ -9,15 +9,16 @@ namespace Kernel::USB { -ErrorOr<NonnullLockRefPtr<Transfer>> Transfer::try_create(Pipe& pipe, u16 length, Memory::Region& dma_buffer) +ErrorOr<NonnullLockRefPtr<Transfer>> Transfer::create(Pipe& pipe, u16 length, Memory::Region& dma_buffer, USBAsyncCallback callback) { - return adopt_nonnull_lock_ref_or_enomem(new (nothrow) Transfer(pipe, length, dma_buffer)); + return adopt_nonnull_lock_ref_or_enomem(new (nothrow) Transfer(pipe, length, dma_buffer, move(callback))); } -Transfer::Transfer(Pipe& pipe, u16 len, Memory::Region& dma_buffer) +Transfer::Transfer(Pipe& pipe, u16 len, Memory::Region& dma_buffer, USBAsyncCallback callback) : m_pipe(pipe) , m_dma_buffer(dma_buffer) , m_transfer_data_size(len) + , m_callback(move(callback)) { } @@ -49,4 +50,10 @@ ErrorOr<void> Transfer::write_buffer(u16 len, void* data) return {}; } +void Transfer::invoke_async_callback() +{ + if (m_callback) + m_callback(this); +} + } |