diff options
author | Russell King - ARM Linux <linux@arm.linux.org.uk> | 2011-01-03 17:35:49 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-01-04 22:16:11 -0500 |
commit | ac3cd20df9d74bb205bb34f69407477a884ff8a3 (patch) | |
tree | 6a740291ec8c7b05cd7647c8dc0d90c5c0d0d68e /drivers/dma | |
parent | 7cb72ad959b16ac594118977b7954a7d2ec7a052 (diff) |
ARM: PL08x: consolidate common txd initialization
Consolidate code which allocates and initializes txds.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index fada97873d7d..d47255ee9504 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -1363,6 +1363,18 @@ static int pl08x_prep_channel_resources(struct pl08x_dma_chan *plchan, | |||
1363 | return 0; | 1363 | return 0; |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | static struct pl08x_txd *pl08x_get_txd(struct pl08x_dma_chan *plchan) | ||
1367 | { | ||
1368 | struct pl08x_txd *txd = kzalloc(sizeof(struct pl08x_txd), GFP_NOWAIT); | ||
1369 | |||
1370 | if (txd) { | ||
1371 | dma_async_tx_descriptor_init(&txd->tx, &plchan->chan); | ||
1372 | txd->tx.tx_submit = pl08x_tx_submit; | ||
1373 | INIT_LIST_HEAD(&txd->node); | ||
1374 | } | ||
1375 | return txd; | ||
1376 | } | ||
1377 | |||
1366 | /* | 1378 | /* |
1367 | * Initialize a descriptor to be used by memcpy submit | 1379 | * Initialize a descriptor to be used by memcpy submit |
1368 | */ | 1380 | */ |
@@ -1375,14 +1387,13 @@ static struct dma_async_tx_descriptor *pl08x_prep_dma_memcpy( | |||
1375 | struct pl08x_txd *txd; | 1387 | struct pl08x_txd *txd; |
1376 | int ret; | 1388 | int ret; |
1377 | 1389 | ||
1378 | txd = kzalloc(sizeof(struct pl08x_txd), GFP_NOWAIT); | 1390 | txd = pl08x_get_txd(plchan); |
1379 | if (!txd) { | 1391 | if (!txd) { |
1380 | dev_err(&pl08x->adev->dev, | 1392 | dev_err(&pl08x->adev->dev, |
1381 | "%s no memory for descriptor\n", __func__); | 1393 | "%s no memory for descriptor\n", __func__); |
1382 | return NULL; | 1394 | return NULL; |
1383 | } | 1395 | } |
1384 | 1396 | ||
1385 | dma_async_tx_descriptor_init(&txd->tx, chan); | ||
1386 | txd->direction = DMA_NONE; | 1397 | txd->direction = DMA_NONE; |
1387 | txd->srcbus.addr = src; | 1398 | txd->srcbus.addr = src; |
1388 | txd->dstbus.addr = dest; | 1399 | txd->dstbus.addr = dest; |
@@ -1391,12 +1402,8 @@ static struct dma_async_tx_descriptor *pl08x_prep_dma_memcpy( | |||
1391 | txd->cd = &pl08x->pd->memcpy_channel; | 1402 | txd->cd = &pl08x->pd->memcpy_channel; |
1392 | /* Both to be incremented or the code will break */ | 1403 | /* Both to be incremented or the code will break */ |
1393 | txd->cd->cctl |= PL080_CONTROL_SRC_INCR | PL080_CONTROL_DST_INCR; | 1404 | txd->cd->cctl |= PL080_CONTROL_SRC_INCR | PL080_CONTROL_DST_INCR; |
1394 | txd->tx.tx_submit = pl08x_tx_submit; | ||
1395 | txd->tx.callback = NULL; | ||
1396 | txd->tx.callback_param = NULL; | ||
1397 | txd->len = len; | 1405 | txd->len = len; |
1398 | 1406 | ||
1399 | INIT_LIST_HEAD(&txd->node); | ||
1400 | ret = pl08x_prep_channel_resources(plchan, txd); | 1407 | ret = pl08x_prep_channel_resources(plchan, txd); |
1401 | if (ret) | 1408 | if (ret) |
1402 | return NULL; | 1409 | return NULL; |
@@ -1430,14 +1437,12 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg( | |||
1430 | dev_dbg(&pl08x->adev->dev, "%s prepare transaction of %d bytes from %s\n", | 1437 | dev_dbg(&pl08x->adev->dev, "%s prepare transaction of %d bytes from %s\n", |
1431 | __func__, sgl->length, plchan->name); | 1438 | __func__, sgl->length, plchan->name); |
1432 | 1439 | ||
1433 | txd = kzalloc(sizeof(struct pl08x_txd), GFP_NOWAIT); | 1440 | txd = pl08x_get_txd(plchan); |
1434 | if (!txd) { | 1441 | if (!txd) { |
1435 | dev_err(&pl08x->adev->dev, "%s no txd\n", __func__); | 1442 | dev_err(&pl08x->adev->dev, "%s no txd\n", __func__); |
1436 | return NULL; | 1443 | return NULL; |
1437 | } | 1444 | } |
1438 | 1445 | ||
1439 | dma_async_tx_descriptor_init(&txd->tx, chan); | ||
1440 | |||
1441 | if (direction != plchan->runtime_direction) | 1446 | if (direction != plchan->runtime_direction) |
1442 | dev_err(&pl08x->adev->dev, "%s DMA setup does not match " | 1447 | dev_err(&pl08x->adev->dev, "%s DMA setup does not match " |
1443 | "the direction configured for the PrimeCell\n", | 1448 | "the direction configured for the PrimeCell\n", |
@@ -1467,11 +1472,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg( | |||
1467 | return NULL; | 1472 | return NULL; |
1468 | } | 1473 | } |
1469 | txd->cd = plchan->cd; | 1474 | txd->cd = plchan->cd; |
1470 | txd->tx.tx_submit = pl08x_tx_submit; | ||
1471 | txd->tx.callback = NULL; | ||
1472 | txd->tx.callback_param = NULL; | ||
1473 | txd->len = sgl->length; | 1475 | txd->len = sgl->length; |
1474 | INIT_LIST_HEAD(&txd->node); | ||
1475 | 1476 | ||
1476 | ret = pl08x_prep_channel_resources(plchan, txd); | 1477 | ret = pl08x_prep_channel_resources(plchan, txd); |
1477 | if (ret) | 1478 | if (ret) |