aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/common/edma.c
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.csengg@gmail.com>2013-06-17 10:57:58 -0400
committerSekhar Nori <nsekhar@ti.com>2013-06-18 04:34:11 -0400
commite7eff702e086bb049bcf33c1338323165f3ec89e (patch)
treee97abe18972e2acccae69008bc0c5cf622f343f5 /arch/arm/common/edma.c
parent7bb5d75ce91ca3725256c0d502624ed697231cde (diff)
ARM: edma: Convert to devm_* api
Use devm_ioremap_resource instead of reques_mem_region()/ioremap(), devm_request_irq() instead of request_irq() and kzalloc() calls to devm_kzalloc(). This ensures more consistent error values and simplifies error paths. Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> [nsekhar@ti.com: add missing err.h include] Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Diffstat (limited to 'arch/arm/common/edma.c')
-rw-r--r--arch/arm/common/edma.c65
1 files changed, 20 insertions, 45 deletions
diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
index a1db6cd8cf79..7658874cc3d5 100644
--- a/arch/arm/common/edma.c
+++ b/arch/arm/common/edma.c
@@ -17,6 +17,7 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20#include <linux/err.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/init.h> 22#include <linux/init.h>
22#include <linux/module.h> 23#include <linux/module.h>
@@ -1382,7 +1383,6 @@ static int __init edma_probe(struct platform_device *pdev)
1382 int irq[EDMA_MAX_CC] = {0, 0}; 1383 int irq[EDMA_MAX_CC] = {0, 0};
1383 int err_irq[EDMA_MAX_CC] = {0, 0}; 1384 int err_irq[EDMA_MAX_CC] = {0, 0};
1384 struct resource *r[EDMA_MAX_CC] = {NULL}; 1385 struct resource *r[EDMA_MAX_CC] = {NULL};
1385 resource_size_t len[EDMA_MAX_CC];
1386 char res_name[10]; 1386 char res_name[10];
1387 char irq_name[10]; 1387 char irq_name[10];
1388 1388
@@ -1402,26 +1402,14 @@ static int __init edma_probe(struct platform_device *pdev)
1402 found = 1; 1402 found = 1;
1403 } 1403 }
1404 1404
1405 len[j] = resource_size(r[j]); 1405 edmacc_regs_base[j] = devm_ioremap_resource(&pdev->dev, r[j]);
1406 if (IS_ERR(edmacc_regs_base[j]))
1407 return PTR_ERR(edmacc_regs_base[j]);
1406 1408
1407 r[j] = request_mem_region(r[j]->start, len[j], 1409 edma_cc[j] = devm_kzalloc(&pdev->dev, sizeof(struct edma),
1408 dev_name(&pdev->dev)); 1410 GFP_KERNEL);
1409 if (!r[j]) { 1411 if (!edma_cc[j])
1410 status = -EBUSY; 1412 return -ENOMEM;
1411 goto fail1;
1412 }
1413
1414 edmacc_regs_base[j] = ioremap(r[j]->start, len[j]);
1415 if (!edmacc_regs_base[j]) {
1416 status = -EBUSY;
1417 goto fail1;
1418 }
1419
1420 edma_cc[j] = kzalloc(sizeof(struct edma), GFP_KERNEL);
1421 if (!edma_cc[j]) {
1422 status = -ENOMEM;
1423 goto fail1;
1424 }
1425 1413
1426 edma_cc[j]->num_channels = min_t(unsigned, info[j]->n_channel, 1414 edma_cc[j]->num_channels = min_t(unsigned, info[j]->n_channel,
1427 EDMA_MAX_DMACH); 1415 EDMA_MAX_DMACH);
@@ -1471,23 +1459,27 @@ static int __init edma_probe(struct platform_device *pdev)
1471 sprintf(irq_name, "edma%d", j); 1459 sprintf(irq_name, "edma%d", j);
1472 irq[j] = platform_get_irq_byname(pdev, irq_name); 1460 irq[j] = platform_get_irq_byname(pdev, irq_name);
1473 edma_cc[j]->irq_res_start = irq[j]; 1461 edma_cc[j]->irq_res_start = irq[j];
1474 status = request_irq(irq[j], dma_irq_handler, 0, "edma", 1462 status = devm_request_irq(&pdev->dev, irq[j],
1475 &pdev->dev); 1463 dma_irq_handler, 0, "edma",
1464 &pdev->dev);
1476 if (status < 0) { 1465 if (status < 0) {
1477 dev_dbg(&pdev->dev, "request_irq %d failed --> %d\n", 1466 dev_dbg(&pdev->dev,
1467 "devm_request_irq %d failed --> %d\n",
1478 irq[j], status); 1468 irq[j], status);
1479 goto fail; 1469 return status;
1480 } 1470 }
1481 1471
1482 sprintf(irq_name, "edma%d_err", j); 1472 sprintf(irq_name, "edma%d_err", j);
1483 err_irq[j] = platform_get_irq_byname(pdev, irq_name); 1473 err_irq[j] = platform_get_irq_byname(pdev, irq_name);
1484 edma_cc[j]->irq_res_end = err_irq[j]; 1474 edma_cc[j]->irq_res_end = err_irq[j];
1485 status = request_irq(err_irq[j], dma_ccerr_handler, 0, 1475 status = devm_request_irq(&pdev->dev, err_irq[j],
1486 "edma_error", &pdev->dev); 1476 dma_ccerr_handler, 0,
1477 "edma_error", &pdev->dev);
1487 if (status < 0) { 1478 if (status < 0) {
1488 dev_dbg(&pdev->dev, "request_irq %d failed --> %d\n", 1479 dev_dbg(&pdev->dev,
1480 "devm_request_irq %d failed --> %d\n",
1489 err_irq[j], status); 1481 err_irq[j], status);
1490 goto fail; 1482 return status;
1491 } 1483 }
1492 1484
1493 for (i = 0; i < edma_cc[j]->num_channels; i++) 1485 for (i = 0; i < edma_cc[j]->num_channels; i++)
@@ -1522,23 +1514,6 @@ static int __init edma_probe(struct platform_device *pdev)
1522 } 1514 }
1523 1515
1524 return 0; 1516 return 0;
1525
1526fail:
1527 for (i = 0; i < EDMA_MAX_CC; i++) {
1528 if (err_irq[i])
1529 free_irq(err_irq[i], &pdev->dev);
1530 if (irq[i])
1531 free_irq(irq[i], &pdev->dev);
1532 }
1533fail1:
1534 for (i = 0; i < EDMA_MAX_CC; i++) {
1535 if (r[i])
1536 release_mem_region(r[i]->start, len[i]);
1537 if (edmacc_regs_base[i])
1538 iounmap(edmacc_regs_base[i]);
1539 kfree(edma_cc[i]);
1540 }
1541 return status;
1542} 1517}
1543 1518
1544 1519