diff options
author | Chaitanya Bandi <bandik@nvidia.com> | 2014-04-03 15:33:02 +0530 |
---|---|---|
committer | Laxman Dewangan <ldewangan@nvidia.com> | 2014-04-07 02:21:31 -0700 |
commit | 2f8400aa8cf763c80ec9739a33d3cc6808d8d541 (patch) | |
tree | b1e030ee04f8a633c4a76f9abb16398b37599948 /drivers/dma | |
parent | dd46c0e5d1afdf0d7549e872ac03b5a18c1334e4 (diff) |
dma: add dma_get_any_slave_channel(), for use in of_xlate()
Added dma_get_any_slave_channel() API for use in
of_xlate().
Cherry-picked manually from commit 8010dad55a0ab0e829f3733854e5235eef4e2734
Change-Id: If9ed09ac34a76e8cdf9a4271aad750adf4ab1eaf
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Chaitanya Bandi <bandik@nvidia.com>
Reviewed-on: http://git-master/r/389681
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/dmaengine.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 93f7992bee5c..bd5a5f7db9a4 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved. + * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -503,6 +504,51 @@ static struct dma_chan *private_candidate(const dma_cap_mask_t *mask, return NULL; } +struct dma_chan *dma_get_any_slave_channel(struct dma_device *device) +{ + dma_cap_mask_t mask; + struct dma_chan *chan; + int err; + + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + + /* lock against __dma_request_channel */ + mutex_lock(&dma_list_mutex); + + chan = private_candidate(&mask, device, NULL, NULL); + if (chan) { + /* Found a suitable channel, try to grab, prep, and + * return it. We first set DMA_PRIVATE to disable + * balance_ref_count as this channel will not be + * published in the general-purpose allocator + */ + dma_cap_set(DMA_PRIVATE, device->cap_mask); + device->privatecnt++; + err = dma_chan_get(chan); + if (err == -ENODEV) { + pr_debug("%s: %s module removed\n", + __func__, dma_chan_name(chan)); + list_del_rcu(&device->global_node); + } else if (err) { + pr_debug("%s: failed to get %s: (%d)\n", + __func__, dma_chan_name(chan), err); + } else { + mutex_unlock(&dma_list_mutex); + return chan; + } + + if (--device->privatecnt == 0) + dma_cap_clear(DMA_PRIVATE, device->cap_mask); + chan = NULL; + } + + mutex_unlock(&dma_list_mutex); + + return chan; +} +EXPORT_SYMBOL_GPL(dma_get_any_slave_channel); + /** * dma_request_channel - try to allocate an exclusive channel * @mask: capabilities that the channel must satisfy |