diff options
| author | Frank Li <Frank.Li@nxp.com> | 2026-10-02 15:54:09 -0400 |
|---|---|---|
| committer | Vinod Koul <vkoul@kernel.org> | 2026-10-09 11:49:47 +0200 |
| commit | 562b6ed45db52934aaab9fbc856db3db79753155 (patch) | |
| tree | 201f775a0480aaaa02f31227ee3b640f20e25109 /include | |
| parent | 61527d7e6998e87b3acd04f1cd2f4d6814385051 (diff) | |
| download | linux-next-562b6ed45db52934aaab9fbc856db3db79753155.tar.gz linux-next-562b6ed45db52934aaab9fbc856db3db79753155.zip | |
dmaengine: add dmaengine_desc_set_callback() helper
Add a dmaengine_desc_set_callback() inline helper that sets the
callback, callback_result, and callback_param fields of a
dma_async_tx_descriptor together in a single call.
Using this helper instead of open-coding the three field assignments
ensures all three related fields are always updated consistently and
makes call sites more readable.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20261002195410.213610-1-Frank.Li@oss.nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/dmaengine.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 1ee63fdb90a7..1639f8a0a824 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -2060,6 +2060,31 @@ static inline int dmaengine_desc_free(struct dma_async_tx_descriptor *desc) return desc->desc_free(desc); } +/** + * dmaengine_desc_set_callback - set the callback, callback_result and + * parameter on a descriptor + * @tx: the descriptor to set the callback on + * @cb: the plain completion callback, or NULL + * @cb_result: the result-bearing completion callback, or NULL + * @cb_param: the parameter to pass to the callback + * + * Sets the completion callbacks and their shared parameter on a DMA + * transaction descriptor. Use this helper instead of assigning the fields + * directly to ensure all three related fields are updated consistently. + * Only one of @cb and @cb_result should be non-NULL; if both are provided + * @cb_result takes precedence in drivers that support it. + */ +static inline void +dmaengine_desc_set_callback(struct dma_async_tx_descriptor *tx, + dma_async_tx_callback cb, + dma_async_tx_callback_result cb_result, + void *cb_param) +{ + tx->callback = cb; + tx->callback_result = cb_result; + tx->callback_param = cb_param; +} + /* --- DMA device --- */ int dma_async_device_register(struct dma_device *device); |
