[PATCH 1/2] dmaengine: Add cleanup FREE defines for dma_async_tx_descriptor

Frank Li Frank.Li at nxp.com
Thu Oct 2 12:49:41 PDT 2025


Add cleanup FREE defines for dma_async_tx_descriptor to support automatic
cleanup and simplify error handling.

Signed-off-by: Frank Li <Frank.Li at nxp.com>
---
Check patch report exceed 100 chars, but it's still better put into one
line to keep consistent with other DEFINE_FREE and better readablity
---
 include/linux/dmaengine.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 99efe2b9b4ea9844ca6161208362ef18ef111d96..7826b40727ab889c9167343bf15628b83b85647c 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -5,6 +5,7 @@
 #ifndef LINUX_DMAENGINE_H
 #define LINUX_DMAENGINE_H
 
+#include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/uio.h>
@@ -1525,7 +1526,6 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
 struct dma_chan *dma_request_chan(struct device *dev, const char *name);
 struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask);
 struct dma_chan *devm_dma_request_chan(struct device *dev, const char *name);
-
 void dma_release_channel(struct dma_chan *chan);
 int dma_get_slave_caps(struct dma_chan *chan, struct dma_slave_caps *caps);
 #else
@@ -1612,6 +1612,8 @@ static inline int dmaengine_desc_free(struct dma_async_tx_descriptor *desc)
 	return desc->desc_free(desc);
 }
 
+DEFINE_FREE(dma_async_tx_descriptor, struct dma_async_tx_descriptor *, if (_T) dmaengine_desc_free(_T))
+
 /* --- DMA device --- */
 
 int dma_async_device_register(struct dma_device *device);

-- 
2.34.1




More information about the linux-arm-kernel mailing list