From patchwork Tue Jun 25 15:54:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 2777811 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F175F9F756 for ; Tue, 25 Jun 2013 15:58:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B42D5201DD for ; Tue, 25 Jun 2013 15:58:31 +0000 (UTC) Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE0962018E for ; Tue, 25 Jun 2013 15:58:26 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5PFvIaf021736; Tue, 25 Jun 2013 10:57:18 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5PFvHOF005907; Tue, 25 Jun 2013 10:57:17 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Tue, 25 Jun 2013 10:57:17 -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 r5PFvH9n026681; Tue, 25 Jun 2013 10:57:17 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 7EBBC80627; Tue, 25 Jun 2013 10:57:17 -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 58B5C8062B for ; Tue, 25 Jun 2013 10:55:26 -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 r5PFtQxa008493 for ; Tue, 25 Jun 2013 10:55:26 -0500 (CDT) Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5PFtPtN013625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Jun 2013 10:55:25 -0500 Received: from [216.82.250.99:49733] by server-15.bemta-12.messagelabs.com id AA/D2-30971-D6DB9C15; Tue, 25 Jun 2013 15:55:25 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-4.tower-126.messagelabs.com!1372175723!4948421!1 X-Originating-IP: [209.85.220.52] X-SpamReason: No, hits=0.2 required=7.0 tests=ML_RADAR_SPEW_LINKS_14, RCVD_ILLEGAL_IP,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.9; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10282 invoked from network); 25 Jun 2013 15:55:24 -0000 Received: from mail-pa0-f52.google.com (HELO mail-pa0-f52.google.com) (209.85.220.52) by server-4.tower-126.messagelabs.com with RC4-SHA encrypted SMTP; 25 Jun 2013 15:55:24 -0000 Received: by mail-pa0-f52.google.com with SMTP id kq13so12740717pab.25 for ; Tue, 25 Jun 2013 08:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=YQFwWSOJOnhg7b4oEfNs21DHYL638VKCsP1eucQMJWw=; b=Zi3mhxo2Ys3y1gNbIJ1vlGK9Vbli8AjbfhApiNB8XaI2Cm1c5wTGiuE6BiukPMC7gq zwPPhTPZTUNM3K0vZOlWQbwHi6Fm2Yr2TYoc0eLqR6pue8HhM5lbAcmgOyEbyGUk8tQI ayOpnguwTppPPIIpw8hvNu+f4fQMrmzb8xsF+Y6teBVAIOQa00mBvtctxG0HcOPt1yzN RzRF89wzVFpLjjx0SdOs0VsDLDpwgOAfsPdfSfbomvq6yezqRX0bfLN15Di6q/2FqMFa z1YXUVeCJFNuAEwjFQVIwLTEML6m8VBHPSP+CxB3wYLFwfj0cz3l6GsLf3MZuIM29BfO jSew== X-Received: by 10.68.240.72 with SMTP id vy8mr28593531pbc.161.1372175723161; Tue, 25 Jun 2013 08:55:23 -0700 (PDT) Received: from localhost.localdomain ([1.23.213.228]) by mx.google.com with ESMTPSA id fl2sm25799937pab.23.2013.06.25.08.55.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Jun 2013 08:55:22 -0700 (PDT) From: Prabhakar Lad To: David Miller , Subject: [PATCH v2 1/3] net: davinci: emac: Convert to devm_* api Date: Tue, 25 Jun 2013 21:24:51 +0530 Message-ID: <1372175693-20318-2-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1372175693-20318-1-git-send-email-prabhakar.csengg@gmail.com> References: <1372175693-20318-1-git-send-email-prabhakar.csengg@gmail.com> CC: Mugunthan V N , DLOS , 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 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Lad, Prabhakar" Use devm_ioremap_resource instead of devm_request_mem_region()/devm_ioremap() and devm_request_irq() instead of request_irq(). This ensures more consistent error values and simplifies error paths. Signed-off-by: Lad, Prabhakar --- drivers/net/ethernet/ti/davinci_emac.c | 49 ++++++-------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 860e15d..8baf630 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1532,7 +1532,7 @@ static int emac_dev_open(struct net_device *ndev) struct device *emac_dev = &ndev->dev; u32 cnt; struct resource *res; - int q, m, ret; + int ret; int i = 0; int k = 0; struct emac_priv *priv = netdev_priv(ndev); @@ -1567,8 +1567,9 @@ static int emac_dev_open(struct net_device *ndev) while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) { for (i = res->start; i <= res->end; i++) { - if (request_irq(i, emac_irq, IRQF_DISABLED, - ndev->name, ndev)) + if (devm_request_irq(&priv->pdev->dev, i, emac_irq, + IRQF_DISABLED, + ndev->name, ndev)) goto rollback; } k++; @@ -1641,15 +1642,7 @@ static int emac_dev_open(struct net_device *ndev) rollback: - dev_err(emac_dev, "DaVinci EMAC: request_irq() failed"); - - for (q = k; k >= 0; k--) { - for (m = i; m >= res->start; m--) - free_irq(m, ndev); - res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k-1); - m = res->end; - } - + dev_err(emac_dev, "DaVinci EMAC: devm_request_irq() failed"); ret = -EBUSY; err: pm_runtime_put(&priv->pdev->dev); @@ -1667,9 +1660,6 @@ err: */ static int emac_dev_stop(struct net_device *ndev) { - struct resource *res; - int i = 0; - int irq_num; struct emac_priv *priv = netdev_priv(ndev); struct device *emac_dev = &ndev->dev; @@ -1685,13 +1675,6 @@ static int emac_dev_stop(struct net_device *ndev) if (priv->phydev) phy_disconnect(priv->phydev); - /* Free IRQ */ - while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, i))) { - for (irq_num = res->start; irq_num <= res->end; irq_num++) - free_irq(irq_num, priv->ndev); - i++; - } - if (netif_msg_drv(priv)) dev_notice(emac_dev, "DaVinci EMAC: %s stopped\n", ndev->name); @@ -1856,7 +1839,7 @@ static int davinci_emac_probe(struct platform_device *pdev) struct resource *res; struct net_device *ndev; struct emac_priv *priv; - unsigned long size, hw_ram_addr; + unsigned long hw_ram_addr; struct emac_platform_data *pdata; struct device *emac_dev; struct cpdma_params dma_params; @@ -1907,25 +1890,11 @@ static int davinci_emac_probe(struct platform_device *pdev) emac_dev = &ndev->dev; /* Get EMAC platform data */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev,"error getting res\n"); - rc = -ENOENT; - goto no_pdata; - } - priv->emac_base_phys = res->start + pdata->ctrl_reg_offset; - size = resource_size(res); - if (!devm_request_mem_region(&pdev->dev, res->start, - size, ndev->name)) { - dev_err(&pdev->dev, "failed request_mem_region() for regs\n"); - rc = -ENXIO; - goto no_pdata; - } - - priv->remap_addr = devm_ioremap(&pdev->dev, res->start, size); - if (!priv->remap_addr) { + priv->remap_addr = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(priv->remap_addr)) { dev_err(&pdev->dev, "unable to map IO\n"); - rc = -ENOMEM; + rc = PTR_ERR(priv->remap_addr); goto no_pdata; } priv->emac_base = priv->remap_addr + pdata->ctrl_reg_offset;