From patchwork Wed Feb 12 15:55:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3639101 Return-Path: X-Original-To: patchwork-linux-arm@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 2DE279F334 for ; Wed, 12 Feb 2014 16:28:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4550A201EC for ; Wed, 12 Feb 2014 16:28:36 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E0B120142 for ; Wed, 12 Feb 2014 16:28:35 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDcDv-0000ga-5A; Wed, 12 Feb 2014 15:59:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDcD6-0007Sx-H9; Wed, 12 Feb 2014 15:58:52 +0000 Received: from mail-ea0-f171.google.com ([209.85.215.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDcBt-0007Gs-8F for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2014 15:57:40 +0000 Received: by mail-ea0-f171.google.com with SMTP id f15so4559790eak.30 for ; Wed, 12 Feb 2014 07:57:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:content-type; bh=FXJF4HYQqFNeHyJHXqPpXiWuQrOrIiXXahMwvBmIzps=; b=R9SnDcaHOSJy+jPzkjOergc7QgMcW4X7ZtUEoqJHKHnXC1THThfU3UAwgJsInVFn47 E2XId1j7h2XRO3cooufIls80AcznqVPa3eaXmWFrAqxmQfAafb7KKN4NVnHrpstwBZlW 0WAmXdFNkehJpYHbOySztTOXOzPLB66zqlkGhNVvdv0BgJn5Y5yzlOAfFAefsCKq41// YHbYGZDcrIQblAVXLd07dvOWG41EWs6VLHiZgKIlck/VSuIMB5ziaB6tfc3mWRyUD9+/ ednUgY2vxvpK1nwXfzdgWtTYv0Stl86tJFazpbm4gGt1QQOFcPtxcctO3WYnoyBsMfVi 7rpw== X-Gm-Message-State: ALoCoQlrb5uoI+7uMKRx86HEA1tDNkMXDA0iC+WR3kW7TWfYmAcrtBXGdFGofEnoj1Q8IPWRfgqh X-Received: by 10.14.111.201 with SMTP id w49mr3124095eeg.92.1392220635218; Wed, 12 Feb 2014 07:57:15 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id n41sm53257141eeg.16.2014.02.12.07.57.12 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 12 Feb 2014 07:57:13 -0800 (PST) From: Michal Simek To: netdev@vger.kernel.org Subject: [PATCH 11/14] net: axienet: Use devm_* calls Date: Wed, 12 Feb 2014 16:55:45 +0100 Message-Id: <1b09a985cd055344d7ff874eb27b30c9c3b27c6a.1392220536.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140212_105737_608443_F7CA0B80 X-CRM114-Status: GOOD ( 18.29 ) X-Spam-Score: -1.9 (-) Cc: Srikanth Thokala , linux-kernel@vger.kernel.org, Michal Simek , Srikanth Thokala , Anirudha Sarangi , John Linn , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS, UNPARSEABLE_RELAY autolearn=unavailable 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: Srikanth Thokala use devm_* calls Signed-off-by: Srikanth Thokala Signed-off-by: Michal Simek --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 54 ++++++++++++----------- 1 file changed, 28 insertions(+), 26 deletions(-) -- 1.8.2.3 diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 324033c..936a14c 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1499,6 +1499,7 @@ static int axienet_of_probe(struct platform_device *pdev) struct axienet_local *lp; struct net_device *ndev; const void *addr; + struct resource *ethres, dmares; ndev = alloc_etherdev(sizeof(*lp)); if (!ndev) @@ -1518,11 +1519,14 @@ static int axienet_of_probe(struct platform_device *pdev) lp->dev = &pdev->dev; lp->options = XAE_OPTION_DEFAULTS; /* Map device registers */ - lp->regs = of_iomap(pdev->dev.of_node, 0); + ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + lp->regs = devm_ioremap_resource(&pdev->dev, ethres); if (!lp->regs) { dev_err(&pdev->dev, "could not map Axi Ethernet regs.\n"); - goto nodev; + ret = -ENOMEM; + goto free_netdev; } + /* Setup checksum offload, but default to off if not specified */ lp->features = 0; @@ -1584,16 +1588,21 @@ static int axienet_of_probe(struct platform_device *pdev) /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0); - if (!np) { + if (IS_ERR(np)) { dev_err(&pdev->dev, "could not find DMA node\n"); - goto err_iounmap; + ret = PTR_ERR(np); + goto free_netdev; } - lp->dma_regs = of_iomap(np, 0); - if (lp->dma_regs) { - dev_dbg(&pdev->dev, "MEM base: %p\n", lp->dma_regs); - } else { - dev_err(&pdev->dev, "unable to map DMA registers\n"); - of_node_put(np); + ret = of_address_to_resource(np, 0, &dmares); + if (ret) { + dev_err(&pdev->dev, "unable to get DMA resource\n"); + goto free_netdev; + } + lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); + if (!lp->dma_regs) { + dev_err(&pdev->dev, "could not map DMA regs\n"); + ret = -ENOMEM; + goto free_netdev; } lp->rx_irq = irq_of_parse_and_map(np, 1); lp->tx_irq = irq_of_parse_and_map(np, 0); @@ -1601,7 +1610,7 @@ static int axienet_of_probe(struct platform_device *pdev) if ((lp->rx_irq <= 0) || (lp->tx_irq <= 0)) { dev_err(&pdev->dev, "could not determine irqs\n"); ret = -ENOMEM; - goto err_iounmap_2; + goto free_netdev; } /* Retrieve the MAC address */ @@ -1609,7 +1618,7 @@ static int axienet_of_probe(struct platform_device *pdev) if ((!addr) || (size != 6)) { dev_err(&pdev->dev, "could not find MAC address\n"); ret = -ENODEV; - goto err_iounmap_2; + goto free_netdev; } axienet_set_mac_address(ndev, (void *) addr); @@ -1617,27 +1626,23 @@ static int axienet_of_probe(struct platform_device *pdev) lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; lp->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); - if (lp->phy_node) + if (lp->phy_node) { ret = axienet_mdio_setup(lp, pdev->dev.of_node); - if (ret) - dev_warn(&pdev->dev, "error registering MDIO bus\n"); + if (ret) + dev_warn(&pdev->dev, "error registering MDIO bus\n"); + } ret = register_netdev(lp->ndev); if (ret) { dev_err(lp->dev, "register_netdev() error (%i)\n", ret); - goto err_iounmap_2; + goto free_netdev; } return 0; -err_iounmap_2: - if (lp->dma_regs) - iounmap(lp->dma_regs); -err_iounmap: - iounmap(lp->regs); -nodev: +free_netdev: free_netdev(ndev); - ndev = NULL; + return ret; } @@ -1653,9 +1658,6 @@ static int axienet_of_remove(struct platform_device *pdev) of_node_put(lp->phy_node); lp->phy_node = NULL; - iounmap(lp->regs); - if (lp->dma_regs) - iounmap(lp->dma_regs); free_netdev(ndev); return 0;