aboutsummaryrefslogtreecommitdiff
path: root/drivers/dma/sh/shdma-base.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2012-07-05 12:29:41 +0200
committerVinod Koul <vinod.koul@linux.intel.com>2012-07-20 11:23:45 +0530
commitc2cdb7e4d16394fc51dc5c2c5b3e7c3733bdfaac (patch)
tree1e98394a20b33ed09d55b5e37a1c1ed2784721d6 /drivers/dma/sh/shdma-base.c
parentecf90fbbdc66cde6f5fa25d88541112b9baac459 (diff)
dma: sh: use an integer slave ID to improve API compatibility
Initially struct shdma_slave has been introduced with the only member - an unsigned slave ID - to describe common properties of DMA slaves in an extensible way. However, experience shows, that a slave ID is indeed the only parameter, needed to identify DMA slaves. This is also, what is used by the core dmaengine API in struct dma_slave_config. We switch to using the slave_id directly, instead of passing a pointer to struct shdma_slave to improve compatibility with the core. We also make the slave_id signed for easier error checking. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers/dma/sh/shdma-base.c')
-rw-r--r--drivers/dma/sh/shdma-base.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
index f75ebfa735c..73db282a143 100644
--- a/drivers/dma/sh/shdma-base.c
+++ b/drivers/dma/sh/shdma-base.c
@@ -76,7 +76,6 @@ static dma_cookie_t shdma_tx_submit(struct dma_async_tx_descriptor *tx)
container_of(tx, struct shdma_desc, async_tx),
*last = desc;
struct shdma_chan *schan = to_shdma_chan(tx->chan);
- struct shdma_slave *slave = schan->slave;
dma_async_tx_callback callback = tx->callback;
dma_cookie_t cookie;
bool power_up;
@@ -138,7 +137,7 @@ static dma_cookie_t shdma_tx_submit(struct dma_async_tx_descriptor *tx)
* Make it int then, on error remove chunks from the
* queue again
*/
- ops->setup_xfer(schan, slave);
+ ops->setup_xfer(schan, schan->slave_id);
if (schan->pm_state == SHDMA_PM_PENDING)
shdma_chan_xfer_ld_queue(schan);
@@ -186,7 +185,7 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
* never runs concurrently with itself or free_chan_resources.
*/
if (slave) {
- if (slave->slave_id >= slave_num) {
+ if (slave->slave_id < 0 || slave->slave_id >= slave_num) {
ret = -EINVAL;
goto evalid;
}
@@ -196,9 +195,13 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
goto etestused;
}
- ret = ops->set_slave(schan, slave);
+ ret = ops->set_slave(schan, slave->slave_id);
if (ret < 0)
goto esetslave;
+
+ schan->slave_id = slave->slave_id;
+ } else {
+ schan->slave_id = -EINVAL;
}
schan->desc = kcalloc(NR_DESCS_PER_CHANNEL,
@@ -208,7 +211,6 @@ static int shdma_alloc_chan_resources(struct dma_chan *chan)
goto edescalloc;
}
schan->desc_num = NR_DESCS_PER_CHANNEL;
- schan->slave = slave;
for (i = 0; i < NR_DESCS_PER_CHANNEL; i++) {
desc = ops->embedded_desc(schan->desc, i);
@@ -366,10 +368,9 @@ static void shdma_free_chan_resources(struct dma_chan *chan)
if (!list_empty(&schan->ld_queue))
shdma_chan_ld_cleanup(schan, true);
- if (schan->slave) {
+ if (schan->slave_id >= 0) {
/* The caller is holding dma_list_mutex */
- struct shdma_slave *slave = schan->slave;
- clear_bit(slave->slave_id, shdma_slave_used);
+ clear_bit(schan->slave_id, shdma_slave_used);
chan->private = NULL;
}
@@ -559,7 +560,7 @@ static struct dma_async_tx_descriptor *shdma_prep_slave_sg(
struct shdma_chan *schan = to_shdma_chan(chan);
struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
const struct shdma_ops *ops = sdev->ops;
- struct shdma_slave *slave = schan->slave;
+ int slave_id = schan->slave_id;
dma_addr_t slave_addr;
if (!chan)
@@ -568,9 +569,9 @@ static struct dma_async_tx_descriptor *shdma_prep_slave_sg(
BUG_ON(!schan->desc_num);
/* Someone calling slave DMA on a generic channel? */
- if (!slave || !sg_len) {
- dev_warn(schan->dev, "%s: bad parameter: %p, %d, %d\n",
- __func__, slave, sg_len, slave ? slave->slave_id : -1);
+ if (slave_id < 0 || !sg_len) {
+ dev_warn(schan->dev, "%s: bad parameter: len=%d, id=%d\n",
+ __func__, sg_len, slave_id);
return NULL;
}