aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2011-01-25 05:18:19 -0500
committerDan Williams <dan.j.williams@intel.com>2011-01-31 01:27:18 -0500
commitdbd887880320b6a56811bb38ff4ad888728c3a91 (patch)
tree0825398570e258b43dbdb731ed9df20d32d2f039
parent5f81158f90db4bc8a79e91736aa3afce8e590e46 (diff)
dma40: combine duplicated d40_pool_lli_alloc() calls
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>
-rw-r--r--drivers/dma/ste_dma40.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 5259a9832435..495f9eb0a4b6 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -332,8 +332,9 @@ static void __iomem *chan_base(struct d40_chan *chan)
332 d40_err(chan2dev(d40c), format, ## arg) 332 d40_err(chan2dev(d40c), format, ## arg)
333 333
334static int d40_pool_lli_alloc(struct d40_chan *d40c, struct d40_desc *d40d, 334static int d40_pool_lli_alloc(struct d40_chan *d40c, struct d40_desc *d40d,
335 int lli_len, bool is_log) 335 int lli_len)
336{ 336{
337 bool is_log = chan_is_logical(d40c);
337 u32 align; 338 u32 align;
338 void *base; 339 void *base;
339 340
@@ -1623,6 +1624,7 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
1623{ 1624{
1624 struct stedma40_chan_cfg *cfg = &chan->dma_cfg; 1625 struct stedma40_chan_cfg *cfg = &chan->dma_cfg;
1625 struct d40_desc *desc; 1626 struct d40_desc *desc;
1627 int ret;
1626 1628
1627 desc = d40_desc_get(chan); 1629 desc = d40_desc_get(chan);
1628 if (!desc) 1630 if (!desc)
@@ -1632,11 +1634,16 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
1632 cfg->dst_info.data_width); 1634 cfg->dst_info.data_width);
1633 if (desc->lli_len < 0) { 1635 if (desc->lli_len < 0) {
1634 chan_err(chan, "Unaligned size\n"); 1636 chan_err(chan, "Unaligned size\n");
1635 d40_desc_free(chan, desc); 1637 goto err;
1638 }
1636 1639
1637 return NULL; 1640 ret = d40_pool_lli_alloc(chan, desc, desc->lli_len);
1641 if (ret < 0) {
1642 chan_err(chan, "Could not allocate lli\n");
1643 goto err;
1638 } 1644 }
1639 1645
1646
1640 desc->lli_current = 0; 1647 desc->lli_current = 0;
1641 desc->txd.flags = dma_flags; 1648 desc->txd.flags = dma_flags;
1642 desc->txd.tx_submit = d40_tx_submit; 1649 desc->txd.tx_submit = d40_tx_submit;
@@ -1644,6 +1651,10 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
1644 dma_async_tx_descriptor_init(&desc->txd, &chan->chan); 1651 dma_async_tx_descriptor_init(&desc->txd, &chan->chan);
1645 1652
1646 return desc; 1653 return desc;
1654
1655err:
1656 d40_desc_free(chan, desc);
1657 return NULL;
1647} 1658}
1648 1659
1649struct dma_async_tx_descriptor *stedma40_memcpy_sg(struct dma_chan *chan, 1660struct dma_async_tx_descriptor *stedma40_memcpy_sg(struct dma_chan *chan,
@@ -1670,12 +1681,6 @@ struct dma_async_tx_descriptor *stedma40_memcpy_sg(struct dma_chan *chan,
1670 goto err; 1681 goto err;
1671 1682
1672 if (chan_is_logical(d40c)) { 1683 if (chan_is_logical(d40c)) {
1673
1674 if (d40_pool_lli_alloc(d40c, d40d, d40d->lli_len, true) < 0) {
1675 chan_err(d40c, "Out of memory\n");
1676 goto err;
1677 }
1678
1679 (void) d40_log_sg_to_lli(sgl_src, 1684 (void) d40_log_sg_to_lli(sgl_src,
1680 sgl_len, 1685 sgl_len,
1681 d40d->lli_log.src, 1686 d40d->lli_log.src,
@@ -1690,11 +1695,6 @@ struct dma_async_tx_descriptor *stedma40_memcpy_sg(struct dma_chan *chan,
1690 d40c->dma_cfg.dst_info.data_width, 1695 d40c->dma_cfg.dst_info.data_width,
1691 d40c->dma_cfg.src_info.data_width); 1696 d40c->dma_cfg.src_info.data_width);
1692 } else { 1697 } else {
1693 if (d40_pool_lli_alloc(d40c, d40d, d40d->lli_len, false) < 0) {
1694 chan_err(d40c, "Out of memory\n");
1695 goto err;
1696 }
1697
1698 res = d40_phy_sg_to_lli(sgl_src, 1698 res = d40_phy_sg_to_lli(sgl_src,
1699 sgl_len, 1699 sgl_len,
1700 0, 1700 0,
@@ -1914,11 +1914,6 @@ static int d40_prep_slave_sg_log(struct d40_desc *d40d,
1914 dma_addr_t dev_addr = 0; 1914 dma_addr_t dev_addr = 0;
1915 int total_size; 1915 int total_size;
1916 1916
1917 if (d40_pool_lli_alloc(d40c, d40d, d40d->lli_len, true) < 0) {
1918 chan_err(d40c, "Out of memory\n");
1919 return -ENOMEM;
1920 }
1921
1922 if (direction == DMA_FROM_DEVICE) 1917 if (direction == DMA_FROM_DEVICE)
1923 if (d40c->runtime_addr) 1918 if (d40c->runtime_addr)
1924 dev_addr = d40c->runtime_addr; 1919 dev_addr = d40c->runtime_addr;
@@ -1958,11 +1953,6 @@ static int d40_prep_slave_sg_phy(struct d40_desc *d40d,
1958 dma_addr_t dst_dev_addr; 1953 dma_addr_t dst_dev_addr;
1959 int res; 1954 int res;
1960 1955
1961 if (d40_pool_lli_alloc(d40c, d40d, d40d->lli_len, false) < 0) {
1962 chan_err(d40c, "Out of memory\n");
1963 return -ENOMEM;
1964 }
1965
1966 if (direction == DMA_FROM_DEVICE) { 1956 if (direction == DMA_FROM_DEVICE) {
1967 dst_dev_addr = 0; 1957 dst_dev_addr = 0;
1968 if (d40c->runtime_addr) 1958 if (d40c->runtime_addr)