From bbc109e0e686266d784483df108af206bc52e120 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 5 Oct 2026 05:37:17 -0400 Subject: dmaengine: add dmaengine_get_cap_mask() and dmaengine_has_cap() helpers Add two new inline helpers to query DMA channel capabilities without directly accessing the internal dma_device pointer: dmaengine_get_cap_mask(chan) - returns a const pointer to the capability mask of the DMA device backing the channel. dmaengine_has_cap(chan, tx_type) - returns true if the channel supports the given transaction type. These complement the existing dma_has_cap() macro which operates on a dma_cap_mask_t directly. Signed-off-by: Frank Li Link: https://patch.msgid.link/20261005-dmaengine_prep_dma_pq-v3-4-a4a241f26fa7@nxp.com Signed-off-by: Vinod Koul --- include/linux/dmaengine.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index efe421503501..4e4e1cc22b9a 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -1605,6 +1605,18 @@ dmaengine_get_fill_align(struct dma_chan *chan) return chan->device->fill_align; } +/** + * dmaengine_get_cap_mask - get capability mask of a DMA channel + * @chan: DMA channel + * + * Return a pointer to the capability mask of the DMA device backing @chan. + */ +static inline const dma_cap_mask_t * +dmaengine_get_cap_mask(struct dma_chan *chan) +{ + return &chan->device->cap_mask; +} + /** * dmaengine_is_copy_aligned - test copy alignment * @chan: DMA channel @@ -1830,6 +1842,19 @@ __dma_has_cap(enum dma_transaction_type tx_type, dma_cap_mask_t *srcp) return test_bit(tx_type, srcp->bits); } +/** + * dmaengine_has_cap - test whether a DMA channel supports a transaction type + * @chan: DMA channel + * @tx_type: transaction type to test + * + * Return true if @chan supports @tx_type, false otherwise. + */ +static inline bool +dmaengine_has_cap(struct dma_chan *chan, enum dma_transaction_type tx_type) +{ + return dma_has_cap(tx_type, chan->device->cap_mask); +} + #define for_each_dma_cap_mask(cap, mask) \ for_each_set_bit(cap, mask.bits, DMA_TX_TYPE_END) -- cgit v1.2.3