Skip to content

Commit 9a6cecc

Browse files
Jon HunterVinod Koul
authored andcommitted
dmaengine: add helper function to request a slave DMA channel
Currently slave DMA channels are requested by calling dma_request_channel() and requires DMA clients to pass various filter parameters to obtain the appropriate channel. With device-tree being used by architectures such as arm and the addition of device-tree helper functions to extract the relevant DMA client information from device-tree, add a new function to request a slave DMA channel using device-tree. This function is currently a simple wrapper that calls the device-tree of_dma_request_slave_channel() function. Cc: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Benoit Cousson <b-cousson@ti.com> Cc: Stephen Warren <swarren@nvidia.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Russell King <linux@arm.linux.org.uk> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Vinod Koul <vinod.koul@intel.com> Cc: Dan Williams <djbw@fb.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jon Hunter <jon-hunter@ti.com> Reviewed-by: Stephen Warren <swarren@wwwdotorg.org> Acked-by: Rob Herring <rob.herring@calxeda.com> Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
1 parent d1c3ed6 commit 9a6cecc

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎drivers/dma/dmaengine.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <linux/rculist.h>
6363
#include <linux/idr.h>
6464
#include <linux/slab.h>
65+
#include <linux/of_dma.h>
6566

6667
static DEFINE_MUTEX(dma_list_mutex);
6768
static DEFINE_IDR(dma_idr);
@@ -546,6 +547,21 @@ struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, v
546547
}
547548
EXPORT_SYMBOL_GPL(__dma_request_channel);
548549

550+
/**
551+
* dma_request_slave_channel - try to allocate an exclusive slave channel
552+
* @dev: pointer to client device structure
553+
* @name: slave channel name
554+
*/
555+
struct dma_chan *dma_request_slave_channel(struct device *dev, char *name)
556+
{
557+
/* If device-tree is present get slave info from here */
558+
if (dev->of_node)
559+
return of_dma_request_slave_channel(dev->of_node, name);
560+
561+
return NULL;
562+
}
563+
EXPORT_SYMBOL_GPL(dma_request_slave_channel);
564+
549565
void dma_release_channel(struct dma_chan *chan)
550566
{
551567
mutex_lock(&dma_list_mutex);

‎include/linux/dmaengine.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie);
974974
enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);
975975
void dma_issue_pending_all(void);
976976
struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param);
977+
struct dma_chan *dma_request_slave_channel(struct device *dev, char *name);
977978
void dma_release_channel(struct dma_chan *chan);
978979
#else
979980
static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
@@ -988,6 +989,11 @@ static inline struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask,
988989
{
989990
return NULL;
990991
}
992+
static inline struct dma_chan *dma_request_slave_channel(struct device *dev,
993+
char *name)
994+
{
995+
return NULL
996+
}
991997
static inline void dma_release_channel(struct dma_chan *chan)
992998
{
993999
}

0 commit comments

Comments
 (0)