summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorZhangfei Gao <zhangfei.gao@linaro.org>2013-06-28 20:39:12 +0800
committerChanho Park <chanho61.park@samsung.com>2014-03-20 17:35:23 +0900
commit6df8bded15e8ce453ff84c3953501c040142d0bb (patch)
tree1124594ae5eaa48c1083ca0857b67f397086b6b6 /drivers
parent3f3f0549a7aaa321a468930548dc165f8ab7edc3 (diff)
downloadlinux-3.10-6df8bded15e8ce453ff84c3953501c040142d0bb.tar.gz
linux-3.10-6df8bded15e8ce453ff84c3953501c040142d0bb.tar.bz2
linux-3.10-6df8bded15e8ce453ff84c3953501c040142d0bb.zip
dmaengine: add interface of dma_get_slave_channel
Suggested by Arnd, add dma_get_slave_channel interface Dma host driver could get specific channel specificied by request line, rather than filter. host example: static struct dma_chan *xx_of_dma_simple_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { struct xx_dma_dev *d = ofdma->of_dma_data; unsigned int request = dma_spec->args[0]; if (request > d->dma_requests) return NULL; return dma_get_slave_channel(&(d->chans[request].vc.chan)); } probe: of_dma_controller_register((&op->dev)->of_node, xx_of_dma_simple_xlate, d); Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dma/dmaengine.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 93f7992bee5..78dbbe09d7b 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -504,6 +504,32 @@ static struct dma_chan *private_candidate(const dma_cap_mask_t *mask,
}
/**
+ * dma_request_channel - try to get specific channel exclusively
+ * @chan: target channel
+ */
+struct dma_chan *dma_get_slave_channel(struct dma_chan *chan)
+{
+ int err = -EBUSY;
+
+ /* lock against __dma_request_channel */
+ mutex_lock(&dma_list_mutex);
+
+ if (chan->client_count == 0)
+ err = dma_chan_get(chan);
+ else
+ chan = NULL;
+
+ mutex_unlock(&dma_list_mutex);
+
+ if (err)
+ pr_debug("%s: failed to get %s: (%d)\n",
+ __func__, dma_chan_name(chan), err);
+
+ return chan;
+}
+EXPORT_SYMBOL_GPL(dma_get_slave_channel);
+
+/**
* dma_request_channel - try to allocate an exclusive channel
* @mask: capabilities that the channel must satisfy
* @fn: optional callback to disposition available channels