|
@@ -503,6 +503,32 @@ static struct dma_chan *private_candidate(const dma_cap_mask_t *mask,
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 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
|