diff options
author | Lad, Prabhakar <prabhakar.csengg@gmail.com> | 2013-06-17 20:27:58 +0530 |
---|---|---|
committer | Sekhar Nori <nsekhar@ti.com> | 2013-06-18 14:04:11 +0530 |
commit | e7eff702e086bb049bcf33c1338323165f3ec89e (patch) | |
tree | e97abe18972e2acccae69008bc0c5cf622f343f5 /arch/arm/common | |
parent | 7bb5d75ce91ca3725256c0d502624ed697231cde (diff) | |
download | blackbird-obmc-linux-e7eff702e086bb049bcf33c1338323165f3ec89e.tar.gz blackbird-obmc-linux-e7eff702e086bb049bcf33c1338323165f3ec89e.zip |
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')
-rw-r--r-- | arch/arm/common/edma.c | 65 |
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 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <linux/err.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/module.h> @@ -1382,7 +1383,6 @@ static int __init edma_probe(struct platform_device *pdev) int irq[EDMA_MAX_CC] = {0, 0}; int err_irq[EDMA_MAX_CC] = {0, 0}; struct resource *r[EDMA_MAX_CC] = {NULL}; - resource_size_t len[EDMA_MAX_CC]; char res_name[10]; char irq_name[10]; @@ -1402,26 +1402,14 @@ static int __init edma_probe(struct platform_device *pdev) found = 1; } - len[j] = resource_size(r[j]); + edmacc_regs_base[j] = devm_ioremap_resource(&pdev->dev, r[j]); + if (IS_ERR(edmacc_regs_base[j])) + return PTR_ERR(edmacc_regs_base[j]); - r[j] = request_mem_region(r[j]->start, len[j], - dev_name(&pdev->dev)); - if (!r[j]) { - status = -EBUSY; - goto fail1; - } - - edmacc_regs_base[j] = ioremap(r[j]->start, len[j]); - if (!edmacc_regs_base[j]) { - status = -EBUSY; - goto fail1; - } - - edma_cc[j] = kzalloc(sizeof(struct edma), GFP_KERNEL); - if (!edma_cc[j]) { - status = -ENOMEM; - goto fail1; - } + edma_cc[j] = devm_kzalloc(&pdev->dev, sizeof(struct edma), + GFP_KERNEL); + if (!edma_cc[j]) + return -ENOMEM; edma_cc[j]->num_channels = min_t(unsigned, info[j]->n_channel, EDMA_MAX_DMACH); @@ -1471,23 +1459,27 @@ static int __init edma_probe(struct platform_device *pdev) sprintf(irq_name, "edma%d", j); irq[j] = platform_get_irq_byname(pdev, irq_name); edma_cc[j]->irq_res_start = irq[j]; - status = request_irq(irq[j], dma_irq_handler, 0, "edma", - &pdev->dev); + status = devm_request_irq(&pdev->dev, irq[j], + dma_irq_handler, 0, "edma", + &pdev->dev); if (status < 0) { - dev_dbg(&pdev->dev, "request_irq %d failed --> %d\n", + dev_dbg(&pdev->dev, + "devm_request_irq %d failed --> %d\n", irq[j], status); - goto fail; + return status; } sprintf(irq_name, "edma%d_err", j); err_irq[j] = platform_get_irq_byname(pdev, irq_name); edma_cc[j]->irq_res_end = err_irq[j]; - status = request_irq(err_irq[j], dma_ccerr_handler, 0, - "edma_error", &pdev->dev); + status = devm_request_irq(&pdev->dev, err_irq[j], + dma_ccerr_handler, 0, + "edma_error", &pdev->dev); if (status < 0) { - dev_dbg(&pdev->dev, "request_irq %d failed --> %d\n", + dev_dbg(&pdev->dev, + "devm_request_irq %d failed --> %d\n", err_irq[j], status); - goto fail; + return status; } for (i = 0; i < edma_cc[j]->num_channels; i++) @@ -1522,23 +1514,6 @@ static int __init edma_probe(struct platform_device *pdev) } return 0; - -fail: - for (i = 0; i < EDMA_MAX_CC; i++) { - if (err_irq[i]) - free_irq(err_irq[i], &pdev->dev); - if (irq[i]) - free_irq(irq[i], &pdev->dev); - } -fail1: - for (i = 0; i < EDMA_MAX_CC; i++) { - if (r[i]) - release_mem_region(r[i]->start, len[i]); - if (edmacc_regs_base[i]) - iounmap(edmacc_regs_base[i]); - kfree(edma_cc[i]); - } - return status; } |