diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-05-16 07:20:55 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-07-01 09:15:48 -0400 |
commit | dc8d5f8de12146c8732d926a30e5f064d76061e0 (patch) | |
tree | a44e7117da81c14d86fda0aefca77c8b9a7537d7 /drivers/dma | |
parent | 800d683e6b8f0ba630470a56b61ff6742ad129ad (diff) |
dmaengine: PL08x: get rid of unnecessary checks in dma_slave_config
Get rid of the unnecessary checks in dma_slave_config utilizing
the DMA direction. This allows us to move the computation of
cctl to the prepare function.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index 50b9a839e9c3..f7397789e4e8 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -235,8 +235,6 @@ struct pl08x_dma_chan { | |||
235 | const char *name; | 235 | const char *name; |
236 | const struct pl08x_channel_data *cd; | 236 | const struct pl08x_channel_data *cd; |
237 | struct dma_slave_config cfg; | 237 | struct dma_slave_config cfg; |
238 | u32 src_cctl; | ||
239 | u32 dst_cctl; | ||
240 | struct list_head pend_list; | 238 | struct list_head pend_list; |
241 | struct pl08x_txd *at; | 239 | struct pl08x_txd *at; |
242 | spinlock_t lock; | 240 | spinlock_t lock; |
@@ -1235,30 +1233,15 @@ static int dma_set_runtime_config(struct dma_chan *chan, | |||
1235 | struct dma_slave_config *config) | 1233 | struct dma_slave_config *config) |
1236 | { | 1234 | { |
1237 | struct pl08x_dma_chan *plchan = to_pl08x_chan(chan); | 1235 | struct pl08x_dma_chan *plchan = to_pl08x_chan(chan); |
1238 | struct pl08x_driver_data *pl08x = plchan->host; | ||
1239 | u32 src_cctl, dst_cctl; | ||
1240 | 1236 | ||
1241 | if (!plchan->slave) | 1237 | if (!plchan->slave) |
1242 | return -EINVAL; | 1238 | return -EINVAL; |
1243 | 1239 | ||
1244 | dst_cctl = pl08x_get_cctl(plchan, config->dst_addr_width, | 1240 | /* Reject definitely invalid configurations */ |
1245 | config->dst_maxburst); | 1241 | if (config->src_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES || |
1246 | if (dst_cctl == ~0 && config->direction == DMA_MEM_TO_DEV) { | 1242 | config->dst_addr_width == DMA_SLAVE_BUSWIDTH_8_BYTES) |
1247 | dev_err(&pl08x->adev->dev, | ||
1248 | "bad runtime_config: alien address width (M2D)\n"); | ||
1249 | return -EINVAL; | 1243 | return -EINVAL; |
1250 | } | ||
1251 | 1244 | ||
1252 | src_cctl = pl08x_get_cctl(plchan, config->src_addr_width, | ||
1253 | config->src_maxburst); | ||
1254 | if (src_cctl == ~0 && config->direction == DMA_DEV_TO_MEM) { | ||
1255 | dev_err(&pl08x->adev->dev, | ||
1256 | "bad runtime_config: alien address width (D2M)\n"); | ||
1257 | return -EINVAL; | ||
1258 | } | ||
1259 | |||
1260 | plchan->dst_cctl = dst_cctl; | ||
1261 | plchan->src_cctl = src_cctl; | ||
1262 | plchan->cfg = *config; | 1245 | plchan->cfg = *config; |
1263 | 1246 | ||
1264 | return 0; | 1247 | return 0; |
@@ -1407,7 +1390,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_dma_memcpy( | |||
1407 | 1390 | ||
1408 | /* Set platform data for m2m */ | 1391 | /* Set platform data for m2m */ |
1409 | txd->ccfg |= PL080_FLOW_MEM2MEM << PL080_CONFIG_FLOW_CONTROL_SHIFT; | 1392 | txd->ccfg |= PL080_FLOW_MEM2MEM << PL080_CONFIG_FLOW_CONTROL_SHIFT; |
1410 | txd->cctl = pl08x->pd->memcpy_channel.cctl & | 1393 | txd->cctl = pl08x->pd->memcpy_channel.cctl_memcpy & |
1411 | ~(PL080_CONTROL_DST_AHB2 | PL080_CONTROL_SRC_AHB2); | 1394 | ~(PL080_CONTROL_DST_AHB2 | PL080_CONTROL_SRC_AHB2); |
1412 | 1395 | ||
1413 | /* Both to be incremented or the code will break */ | 1396 | /* Both to be incremented or the code will break */ |
@@ -1434,10 +1417,11 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg( | |||
1434 | struct pl08x_txd *txd; | 1417 | struct pl08x_txd *txd; |
1435 | struct pl08x_sg *dsg; | 1418 | struct pl08x_sg *dsg; |
1436 | struct scatterlist *sg; | 1419 | struct scatterlist *sg; |
1420 | enum dma_slave_buswidth addr_width; | ||
1437 | dma_addr_t slave_addr; | 1421 | dma_addr_t slave_addr; |
1438 | int ret, tmp; | 1422 | int ret, tmp; |
1439 | u8 src_buses, dst_buses; | 1423 | u8 src_buses, dst_buses; |
1440 | u32 cctl; | 1424 | u32 maxburst, cctl; |
1441 | 1425 | ||
1442 | dev_dbg(&pl08x->adev->dev, "%s prepare transaction of %d bytes from %s\n", | 1426 | dev_dbg(&pl08x->adev->dev, "%s prepare transaction of %d bytes from %s\n", |
1443 | __func__, sg_dma_len(sgl), plchan->name); | 1427 | __func__, sg_dma_len(sgl), plchan->name); |
@@ -1456,13 +1440,17 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg( | |||
1456 | txd->direction = direction; | 1440 | txd->direction = direction; |
1457 | 1441 | ||
1458 | if (direction == DMA_MEM_TO_DEV) { | 1442 | if (direction == DMA_MEM_TO_DEV) { |
1459 | cctl = plchan->dst_cctl | PL080_CONTROL_SRC_INCR; | 1443 | cctl = PL080_CONTROL_SRC_INCR; |
1460 | slave_addr = plchan->cfg.dst_addr; | 1444 | slave_addr = plchan->cfg.dst_addr; |
1445 | addr_width = plchan->cfg.dst_addr_width; | ||
1446 | maxburst = plchan->cfg.dst_maxburst; | ||
1461 | src_buses = pl08x->mem_buses; | 1447 | src_buses = pl08x->mem_buses; |
1462 | dst_buses = plchan->cd->periph_buses; | 1448 | dst_buses = plchan->cd->periph_buses; |
1463 | } else if (direction == DMA_DEV_TO_MEM) { | 1449 | } else if (direction == DMA_DEV_TO_MEM) { |
1464 | cctl = plchan->src_cctl | PL080_CONTROL_DST_INCR; | 1450 | cctl = PL080_CONTROL_DST_INCR; |
1465 | slave_addr = plchan->cfg.src_addr; | 1451 | slave_addr = plchan->cfg.src_addr; |
1452 | addr_width = plchan->cfg.src_addr_width; | ||
1453 | maxburst = plchan->cfg.src_maxburst; | ||
1466 | src_buses = plchan->cd->periph_buses; | 1454 | src_buses = plchan->cd->periph_buses; |
1467 | dst_buses = pl08x->mem_buses; | 1455 | dst_buses = pl08x->mem_buses; |
1468 | } else { | 1456 | } else { |
@@ -1472,6 +1460,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg( | |||
1472 | return NULL; | 1460 | return NULL; |
1473 | } | 1461 | } |
1474 | 1462 | ||
1463 | cctl |= pl08x_get_cctl(plchan, addr_width, maxburst); | ||
1475 | if (cctl == ~0) { | 1464 | if (cctl == ~0) { |
1476 | pl08x_free_txd(pl08x, txd); | 1465 | pl08x_free_txd(pl08x, txd); |
1477 | dev_err(&pl08x->adev->dev, | 1466 | dev_err(&pl08x->adev->dev, |
@@ -1774,14 +1763,10 @@ static irqreturn_t pl08x_irq(int irq, void *dev) | |||
1774 | 1763 | ||
1775 | static void pl08x_dma_slave_init(struct pl08x_dma_chan *chan) | 1764 | static void pl08x_dma_slave_init(struct pl08x_dma_chan *chan) |
1776 | { | 1765 | { |
1777 | u32 cctl = pl08x_cctl(chan->cd->cctl); | ||
1778 | |||
1779 | chan->slave = true; | 1766 | chan->slave = true; |
1780 | chan->name = chan->cd->bus_id; | 1767 | chan->name = chan->cd->bus_id; |
1781 | chan->cfg.src_addr = chan->cd->addr; | 1768 | chan->cfg.src_addr = chan->cd->addr; |
1782 | chan->cfg.dst_addr = chan->cd->addr; | 1769 | chan->cfg.dst_addr = chan->cd->addr; |
1783 | chan->src_cctl = cctl; | ||
1784 | chan->dst_cctl = cctl; | ||
1785 | } | 1770 | } |
1786 | 1771 | ||
1787 | /* | 1772 | /* |