File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -926,6 +926,36 @@ void dma_release_channel(struct dma_chan *chan)
926926}
927927EXPORT_SYMBOL_GPL (dma_release_channel );
928928
929+ static void dmaenginem_release_channel (void * chan )
930+ {
931+ dma_release_channel (chan );
932+ }
933+
934+ /**
935+ * devm_dma_request_chan - try to allocate an exclusive slave channel
936+ * @dev: pointer to client device structure
937+ * @name: slave channel name
938+ *
939+ * Returns pointer to appropriate DMA channel on success or an error pointer.
940+ *
941+ * The operation is managed and will be undone on driver detach.
942+ */
943+
944+ struct dma_chan * devm_dma_request_chan (struct device * dev , const char * name )
945+ {
946+ struct dma_chan * chan = dma_request_chan (dev , name );
947+ int ret = 0 ;
948+
949+ if (!IS_ERR (chan ))
950+ ret = devm_add_action_or_reset (dev , dmaenginem_release_channel , chan );
951+
952+ if (ret )
953+ return ERR_PTR (ret );
954+
955+ return chan ;
956+ }
957+ EXPORT_SYMBOL_GPL (devm_dma_request_chan );
958+
929959/**
930960 * dmaengine_get - register interest in dma_channels
931961 */
Original file line number Diff line number Diff line change @@ -1524,6 +1524,7 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
15241524
15251525struct dma_chan * dma_request_chan (struct device * dev , const char * name );
15261526struct dma_chan * dma_request_chan_by_mask (const dma_cap_mask_t * mask );
1527+ struct dma_chan * devm_dma_request_chan (struct device * dev , const char * name );
15271528
15281529void dma_release_channel (struct dma_chan * chan );
15291530int dma_get_slave_caps (struct dma_chan * chan , struct dma_slave_caps * caps );
@@ -1560,6 +1561,12 @@ static inline struct dma_chan *dma_request_chan_by_mask(
15601561{
15611562 return ERR_PTR (- ENODEV );
15621563}
1564+
1565+ static inline struct dma_chan * devm_dma_request_chan (struct device * dev , const char * name )
1566+ {
1567+ return ERR_PTR (- ENODEV );
1568+ }
1569+
15631570static inline void dma_release_channel (struct dma_chan * chan )
15641571{
15651572}
You can’t perform that action at this time.
0 commit comments