From patchwork Thu May 16 06:58:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2575481 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by patchwork1.kernel.org (Postfix) with ESMTP id 4DB0D3FE1F for ; Thu, 16 May 2013 07:01:04 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4G6wlSQ014692; Thu, 16 May 2013 01:58:47 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4G6wkar018831; Thu, 16 May 2013 01:58:46 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Thu, 16 May 2013 01:58:46 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r4G6wk2A007621; Thu, 16 May 2013 01:58:46 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 35F7180627; Thu, 16 May 2013 01:58:46 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id 1D04E80626 for ; Thu, 16 May 2013 01:58:40 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r4G6weDv003262 for ; Thu, 16 May 2013 01:58:40 -0500 (CDT) Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4G6wduL017711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 May 2013 01:58:39 -0500 Received: from [216.82.253.67:24619] by server-4.bemta-7.messagelabs.com id 52/60-04977-F9384915; Thu, 16 May 2013 06:58:39 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-12.tower-158.messagelabs.com!1368687518!3305321!1 X-Originating-IP: [209.85.192.170] X-SpamReason: No, hits=0.0 required=7.0 tests=ML_RADAR_SPEW_LINKS_14, spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22412 invoked from network); 16 May 2013 06:58:38 -0000 Received: from mail-pd0-f170.google.com (HELO mail-pd0-f170.google.com) (209.85.192.170) by server-12.tower-158.messagelabs.com with RC4-SHA encrypted SMTP; 16 May 2013 06:58:38 -0000 Received: by mail-pd0-f170.google.com with SMTP id r10so188139pdi.1 for ; Wed, 15 May 2013 23:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=ofHnMx4zNKxeMePEoO31gnUoQK529VSC5cvFoQ5/EuM=; b=RHHuLz7+SJGu3P1vA3G3DaGkY70moFT644F2lQH3ngmGSsOBjcTTZmso0CFGjcb1QN esruhUTk///b26lLs4zUxUSEqDkB706CYyQGFzJE1TdNWiNfe7+JZheybuBoJlye6cyK eE6qO8QclN2VpAXQBFBkbT2skOgUhWubvQ2EhHe81SHhw3L2m+vwm7ky0Lg0e82Z8RIv NgGSN9ZyYid74/zPoWBMkbRrhJlEltqOrdGUybU1hm7Kyz8eRkJU3Hw3q71R0sgD05SV QKHk02Enh/bOv0KOI9gN8rLGvNlS10iQhdL2bu3KiANzaG+mx7rw9F/38Hypr/hGMK9T EQqA== X-Received: by 10.68.6.168 with SMTP id c8mr21900269pba.184.1368687517766; Wed, 15 May 2013 23:58:37 -0700 (PDT) Received: from localhost.localdomain ([122.166.13.141]) by mx.google.com with ESMTPSA id gc5sm5675770pbb.19.2013.05.15.23.58.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 May 2013 23:58:36 -0700 (PDT) From: Lad Prabhakar To: Sekhar Nori , DLOS , LAK Subject: [PATCH] ARM: davinci: dma: Convert to devm_* api Date: Thu, 16 May 2013 12:28:22 +0530 Message-ID: <1368687502-15551-1-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.4.1 CC: LKML X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: Lad, Prabhakar Use devm_ioremap_resource instead of reques_mem_region()/ioremap() and devm_request_irq() instead of request_irq(). This ensures more consistent error values and simplifies error paths. Signed-off-by: Lad, Prabhakar --- NOte:- Boot tested on Logic-PD OMAP-L138 EVM arch/arm/mach-davinci/dma.c | 63 ++++++++++++++++-------------------------- 1 files changed, 24 insertions(+), 39 deletions(-) diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c index 45b7c71..aeda496 100644 --- a/arch/arm/mach-davinci/dma.c +++ b/arch/arm/mach-davinci/dma.c @@ -1402,7 +1402,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]; @@ -1422,25 +1421,16 @@ static int __init edma_probe(struct platform_device *pdev) found = 1; } - len[j] = resource_size(r[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]) { + edmacc_regs_base[j] = devm_ioremap_resource(&pdev->dev, r[j]); + if (IS_ERR(edmacc_regs_base[j])) { status = -EBUSY; - goto fail1; + goto fail; } edma_cc[j] = kzalloc(sizeof(struct edma), GFP_KERNEL); if (!edma_cc[j]) { status = -ENOMEM; - goto fail1; + goto fail; } edma_cc[j]->num_channels = min_t(unsigned, info[j]->n_channel, @@ -1491,10 +1481,12 @@ 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; } @@ -1502,10 +1494,12 @@ static int __init edma_probe(struct platform_device *pdev) 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; } @@ -1542,17 +1536,20 @@ static int __init edma_probe(struct platform_device *pdev) } if (tc_errs_handled) { - status = request_irq(IRQ_TCERRINT0, dma_tc0err_handler, 0, - "edma_tc0", &pdev->dev); + status = devm_request_irq(&pdev->dev, IRQ_TCERRINT0, + dma_tc0err_handler, 0, + "edma_tc0", &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_TCERRINT0, status); return status; } - status = request_irq(IRQ_TCERRINT, dma_tc1err_handler, 0, - "edma_tc1", &pdev->dev); + status = devm_request_irq(&pdev->dev, IRQ_TCERRINT, + dma_tc1err_handler, 0, + "edma_tc1", &pdev->dev); if (status < 0) { - dev_dbg(&pdev->dev, "request_irq %d --> %d\n", + dev_dbg(&pdev->dev, "devm_request_irq %d --> %d\n", IRQ_TCERRINT, status); return status; } @@ -1561,20 +1558,8 @@ 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]); + for (i = 0; i < EDMA_MAX_CC; i++) kfree(edma_cc[i]); - } return status; }