diff options
| author | Rabin Vincent <rabin.vincent@stericsson.com> | 2011-01-25 05:18:20 -0500 |
|---|---|---|
| committer | Dan Williams <dan.j.williams@intel.com> | 2011-01-31 01:27:18 -0500 |
| commit | 00ac0341486ffe212f45ff1fe0780d12a36fffde (patch) | |
| tree | 5fd79c471c46e2496e1998a20f9d87649171d5e6 | |
| parent | dbd887880320b6a56811bb38ff4ad888728c3a91 (diff) | |
dma40: remove duplicated dev addr code
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.c | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 495f9eb0a4b6..65b5aad1fc4c 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c | |||
| @@ -1909,25 +1909,10 @@ static int d40_prep_slave_sg_log(struct d40_desc *d40d, | |||
| 1909 | struct scatterlist *sgl, | 1909 | struct scatterlist *sgl, |
| 1910 | unsigned int sg_len, | 1910 | unsigned int sg_len, |
| 1911 | enum dma_data_direction direction, | 1911 | enum dma_data_direction direction, |
| 1912 | unsigned long dma_flags) | 1912 | dma_addr_t dev_addr) |
| 1913 | { | 1913 | { |
| 1914 | dma_addr_t dev_addr = 0; | ||
| 1915 | int total_size; | 1914 | int total_size; |
| 1916 | 1915 | ||
| 1917 | if (direction == DMA_FROM_DEVICE) | ||
| 1918 | if (d40c->runtime_addr) | ||
| 1919 | dev_addr = d40c->runtime_addr; | ||
| 1920 | else | ||
| 1921 | dev_addr = d40c->base->plat_data->dev_rx[d40c->dma_cfg.src_dev_type]; | ||
| 1922 | else if (direction == DMA_TO_DEVICE) | ||
| 1923 | if (d40c->runtime_addr) | ||
| 1924 | dev_addr = d40c->runtime_addr; | ||
| 1925 | else | ||
| 1926 | dev_addr = d40c->base->plat_data->dev_tx[d40c->dma_cfg.dst_dev_type]; | ||
| 1927 | |||
| 1928 | else | ||
| 1929 | return -EINVAL; | ||
| 1930 | |||
| 1931 | total_size = d40_log_sg_to_dev(sgl, sg_len, | 1916 | total_size = d40_log_sg_to_dev(sgl, sg_len, |
| 1932 | &d40d->lli_log, | 1917 | &d40d->lli_log, |
| 1933 | &d40c->log_def, | 1918 | &d40c->log_def, |
| @@ -1947,27 +1932,12 @@ static int d40_prep_slave_sg_phy(struct d40_desc *d40d, | |||
| 1947 | struct scatterlist *sgl, | 1932 | struct scatterlist *sgl, |
| 1948 | unsigned int sgl_len, | 1933 | unsigned int sgl_len, |
| 1949 | enum dma_data_direction direction, | 1934 | enum dma_data_direction direction, |
| 1950 | unsigned long dma_flags) | 1935 | dma_addr_t dev_addr) |
| 1951 | { | 1936 | { |
| 1952 | dma_addr_t src_dev_addr; | 1937 | dma_addr_t src_dev_addr = direction == DMA_FROM_DEVICE ? dev_addr : 0; |
| 1953 | dma_addr_t dst_dev_addr; | 1938 | dma_addr_t dst_dev_addr = direction == DMA_TO_DEVICE ? dev_addr : 0; |
| 1954 | int res; | 1939 | int res; |
| 1955 | 1940 | ||
| 1956 | if (direction == DMA_FROM_DEVICE) { | ||
| 1957 | dst_dev_addr = 0; | ||
| 1958 | if (d40c->runtime_addr) | ||
| 1959 | src_dev_addr = d40c->runtime_addr; | ||
| 1960 | else | ||
| 1961 | src_dev_addr = d40c->base->plat_data->dev_rx[d40c->dma_cfg.src_dev_type]; | ||
| 1962 | } else if (direction == DMA_TO_DEVICE) { | ||
| 1963 | if (d40c->runtime_addr) | ||
| 1964 | dst_dev_addr = d40c->runtime_addr; | ||
| 1965 | else | ||
| 1966 | dst_dev_addr = d40c->base->plat_data->dev_tx[d40c->dma_cfg.dst_dev_type]; | ||
| 1967 | src_dev_addr = 0; | ||
| 1968 | } else | ||
| 1969 | return -EINVAL; | ||
| 1970 | |||
| 1971 | res = d40_phy_sg_to_lli(sgl, | 1941 | res = d40_phy_sg_to_lli(sgl, |
| 1972 | sgl_len, | 1942 | sgl_len, |
| 1973 | src_dev_addr, | 1943 | src_dev_addr, |
| @@ -1997,6 +1967,24 @@ static int d40_prep_slave_sg_phy(struct d40_desc *d40d, | |||
| 1997 | return 0; | 1967 | return 0; |
| 1998 | } | 1968 | } |
| 1999 | 1969 | ||
| 1970 | static dma_addr_t | ||
| 1971 | d40_get_dev_addr(struct d40_chan *chan, enum dma_data_direction direction) | ||
| 1972 | { | ||
| 1973 | struct stedma40_platform_data *plat = chan->base->plat_data; | ||
| 1974 | struct stedma40_chan_cfg *cfg = &chan->dma_cfg; | ||
| 1975 | dma_addr_t addr; | ||
| 1976 | |||
| 1977 | if (chan->runtime_addr) | ||
| 1978 | return chan->runtime_addr; | ||
| 1979 | |||
| 1980 | if (direction == DMA_FROM_DEVICE) | ||
| 1981 | addr = plat->dev_rx[cfg->src_dev_type]; | ||
| 1982 | else if (direction == DMA_TO_DEVICE) | ||
| 1983 | addr = plat->dev_tx[cfg->dst_dev_type]; | ||
| 1984 | |||
| 1985 | return addr; | ||
| 1986 | } | ||
| 1987 | |||
| 2000 | static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan, | 1988 | static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan, |
| 2001 | struct scatterlist *sgl, | 1989 | struct scatterlist *sgl, |
| 2002 | unsigned int sg_len, | 1990 | unsigned int sg_len, |
| @@ -2006,6 +1994,7 @@ static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan, | |||
| 2006 | struct d40_desc *d40d; | 1994 | struct d40_desc *d40d; |
| 2007 | struct d40_chan *d40c = container_of(chan, struct d40_chan, | 1995 | struct d40_chan *d40c = container_of(chan, struct d40_chan, |
| 2008 | chan); | 1996 | chan); |
| 1997 | dma_addr_t dev_addr; | ||
| 2009 | unsigned long flags; | 1998 | unsigned long flags; |
| 2010 | int err; | 1999 | int err; |
| 2011 | 2000 | ||
| @@ -2014,18 +2003,23 @@ static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan, | |||
| 2014 | return ERR_PTR(-EINVAL); | 2003 | return ERR_PTR(-EINVAL); |
| 2015 | } | 2004 | } |
| 2016 | 2005 | ||
| 2006 | if (direction != DMA_FROM_DEVICE && direction != DMA_TO_DEVICE) | ||
| 2007 | return NULL; | ||
| 2008 | |||
| 2017 | spin_lock_irqsave(&d40c->lock, flags); | 2009 | spin_lock_irqsave(&d40c->lock, flags); |
| 2018 | 2010 | ||
| 2019 | d40d = d40_prep_desc(d40c, sgl, sg_len, dma_flags); | 2011 | d40d = d40_prep_desc(d40c, sgl, sg_len, dma_flags); |
| 2020 | if (d40d == NULL) | 2012 | if (d40d == NULL) |
| 2021 | goto err; | 2013 | goto err; |
| 2022 | 2014 | ||
| 2015 | dev_addr = d40_get_dev_addr(d40c, direction); | ||
| 2016 | |||
| 2023 | if (chan_is_logical(d40c)) | 2017 | if (chan_is_logical(d40c)) |
| 2024 | err = d40_prep_slave_sg_log(d40d, d40c, sgl, sg_len, | 2018 | err = d40_prep_slave_sg_log(d40d, d40c, sgl, sg_len, |
| 2025 | direction, dma_flags); | 2019 | direction, dev_addr); |
| 2026 | else | 2020 | else |
| 2027 | err = d40_prep_slave_sg_phy(d40d, d40c, sgl, sg_len, | 2021 | err = d40_prep_slave_sg_phy(d40d, d40c, sgl, sg_len, |
| 2028 | direction, dma_flags); | 2022 | direction, dev_addr); |
| 2029 | if (err) { | 2023 | if (err) { |
| 2030 | chan_err(d40c, "Failed to prepare %s slave sg job: %d\n", | 2024 | chan_err(d40c, "Failed to prepare %s slave sg job: %d\n", |
| 2031 | chan_is_logical(d40c) ? "log" : "phy", err); | 2025 | chan_is_logical(d40c) ? "log" : "phy", err); |
