[PATCH v2 07/12] dmaengine: add dmaengine_get_max_xor() helper

From: Frank . Li

Date: Wed Sep 23 2026 - 12:41:56 EST


From: Frank Li <Frank.Li@xxxxxxx>

Add a new inline helper dmaengine_get_max_xor() that returns the maximum
number of XOR source buffers supported by the DMA channel's device.
Returns 0 if the channel is NULL or does not support XOR operations.

Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
---
include/linux/dmaengine.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 7fce44bd7c049..a4c9eef369cb4 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1232,6 +1232,21 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_memcpy(
len, flags);
}

+/**
+ * dmaengine_get_max_xor - get the maximum number of XOR sources for a channel
+ * @chan: DMA channel
+ *
+ * Returns the maximum number of source buffers supported by the XOR engine
+ * behind @chan, or 0 if the channel does not support XOR operations.
+ */
+static inline unsigned int dmaengine_get_max_xor(struct dma_chan *chan)
+{
+ if (!chan || !chan->device)
+ return 0;
+
+ return chan->device->max_xor;
+}
+
/**
* dmaengine_prep_dma_xor - prepare a DMA XOR operation
* @chan: the channel to use for this operation

--
2.43.0