diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2011-01-25 11:18:17 +0100 |
---|---|---|
committer | Rabin VINCENT <rabin.vincent@stericsson.com> | 2011-09-26 11:25:24 +0200 |
commit | b73bd297f5c2709b50ea2347ca5121c140da2156 (patch) | |
tree | ac6364f4b0127cfe57a36708b46cd4ca58285e52 | |
parent | e5bfd807b6229b4e343f2b1dbd5e50e6e95dc398 (diff) |
dma40: implement prep_memcpy as a wrapper around memcpy_sg
To simplify the code.
Change-Id: I960ce6b3cb670b906cca2be9856030f2231ce525
Acked-by: Per Forlin <per.forlin@stericsson.com>
Acked-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/31935
Tested-by: Narayanan GOPALAKRISHNAN <narayanan.gopalakrishnan@stericsson.com>
-rw-r--r-- | drivers/dma/ste_dma40.c | 105 |
1 files changed, 9 insertions, 96 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index b27098730e7..42d5b3eea80 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -2202,106 +2202,19 @@ static struct dma_async_tx_descriptor *d40_prep_memcpy(struct dma_chan *chan, size_t size, unsigned long dma_flags) { - struct d40_desc *d40d; - struct d40_chan *d40c = container_of(chan, struct d40_chan, - chan); - unsigned long flags; - int err = 0; - - if (d40c->phy_chan == NULL) { - chan_err(d40c, "Channel is not allocated.\n"); - return ERR_PTR(-EINVAL); - } - - spin_lock_irqsave(&d40c->lock, flags); - d40d = d40_desc_get(d40c); - - if (d40d == NULL) { - chan_err(d40c, "Descriptor is NULL\n"); - goto err; - } - - d40_usage_inc(d40c); - - d40d->txd.flags = dma_flags; - - dma_async_tx_descriptor_init(&d40d->txd, chan); - - d40d->txd.tx_submit = d40_tx_submit; - - if (chan_is_logical(d40c)) { + struct scatterlist dst_sg; + struct scatterlist src_sg; - if (d40_pool_lli_alloc(d40c, d40d, 1, true) < 0) { - chan_err(d40c, "Out of memory\n"); - goto err2; - } - d40d->lli_len = 1; - d40d->lli_current = 0; - - d40_log_fill_lli(d40d->lli_log.src, - src, - size, - d40c->log_def.lcsp1, - d40c->dma_cfg.src_info.data_width, - true); - - d40_log_fill_lli(d40d->lli_log.dst, - dst, - size, - d40c->log_def.lcsp3, - d40c->dma_cfg.dst_info.data_width, - true); - - } else { - - if (d40_pool_lli_alloc(d40c, d40d, 1, false) < 0) { - chan_err(d40c, "Out of memory\n"); - goto err2; - } - - err = d40_phy_fill_lli(d40d->lli_phy.src, - src, - size, - d40c->dma_cfg.src_info.psize, - 0, - d40c->src_def_cfg, - true, - d40c->dma_cfg.src_info.data_width, - false); - if (err) - goto err_fill_lli; - - err = d40_phy_fill_lli(d40d->lli_phy.dst, - dst, - size, - d40c->dma_cfg.dst_info.psize, - 0, - d40c->dst_def_cfg, - true, - d40c->dma_cfg.dst_info.data_width, - false); - - if (err) - goto err_fill_lli; + sg_init_table(&dst_sg, 1); + sg_init_table(&src_sg, 1); - dma_sync_single_for_device(d40c->base->dev, - d40d->lli_pool.dma_addr, - d40d->lli_pool.size, DMA_TO_DEVICE); - } + sg_dma_address(&dst_sg) = dst; + sg_dma_address(&src_sg) = src; - d40_usage_dec(d40c); - spin_unlock_irqrestore(&d40c->lock, flags); - return &d40d->txd; + sg_dma_len(&dst_sg) = size; + sg_dma_len(&src_sg) = size; -err_fill_lli: - chan_err(d40c, "Failed filling in PHY LLI\n"); -err2: - d40_usage_dec(d40c); -err: - if (d40d) - d40_desc_free(d40c, d40d); - spin_unlock_irqrestore(&d40c->lock, flags); - return NULL; + return stedma40_memcpy_sg(chan, &dst_sg, &src_sg, 1, dma_flags); } static dma_addr_t d40_dev_rx_addr(struct d40_chan *d40c) |