From patchwork Tue May 5 09:26:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 467979 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id DD55C140777 for ; Tue, 5 May 2015 19:28:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031513AbbEEJ1M (ORCPT ); Tue, 5 May 2015 05:27:12 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:33349 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031455AbbEEJ0e (ORCPT ); Tue, 5 May 2015 05:26:34 -0400 Received: by wgin8 with SMTP id n8so175629361wgi.0 for ; Tue, 05 May 2015 02:26:33 -0700 (PDT) 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; bh=fc0nOtfhbW4LuCfY7TqxJZhlnDrf7NVNTMLC4KC5frE=; b=gttign89DZi0EjsYsj+AHyEzOiSBOCLSCc72lMZP3ReFCdODFS3BRnPwDKCPd4yVel lGjiWUWLMwyCCVMdChqGxSQckvhByRHyREmBPeRAcY1bRgtNct+hT8xqKR6L5mPAUk4D jRt81cJ8Y6pOaEpWffNSb7ZbPSW9rscz4X3796L8qyO7ypL/c6tDw3P4RxpWTQB8rvsF Wh/DxMKT5zhP8QmrstuoAPaDm2RgYzR6VY8CyNcXLlOehR+sOvC4duGv7tmr7SQSGSzl Yw20QaqkNTzHc8TgbaaK2gpjl5VNDUFGZUyT1kjbq8FQTVaWHiKra+QAcp6t6DFLUK+Y ynDg== X-Gm-Message-State: ALoCoQlY3weRvWiaHb8SiG7epZue46LbeBj1l0vxFDX+cSRNWN+awpDrFoaKQuEtewh3mf9Rzkn3 X-Received: by 10.180.210.171 with SMTP id mv11mr2169782wic.61.1430817992948; Tue, 05 May 2015 02:26:32 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by mx.google.com with ESMTPSA id i6sm24592373wjf.29.2015.05.05.02.26.31 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 05 May 2015 02:26:31 -0700 (PDT) From: Michal Simek To: netdev@vger.kernel.org Cc: Srikanth Thokala , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , monstr@monstr.eu, John Linn , Anirudha Sarangi , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/12] net: axienet: Use devm_* calls Date: Tue, 5 May 2015 11:26:02 +0200 Message-Id: X-Mailer: git-send-email 2.3.5 In-Reply-To: <7fb84f65a61bbe0fdb4b61a871cf4d4f7910955d.1430817941.git.michal.simek@xilinx.com> References: <7fb84f65a61bbe0fdb4b61a871cf4d4f7910955d.1430817941.git.michal.simek@xilinx.com> In-Reply-To: <7fb84f65a61bbe0fdb4b61a871cf4d4f7910955d.1430817941.git.michal.simek@xilinx.com> References: <7fb84f65a61bbe0fdb4b61a871cf4d4f7910955d.1430817941.git.michal.simek@xilinx.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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, 27 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 757b2dc30cef..49ae4d50774d 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) @@ -1517,12 +1518,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"); ret = -ENOMEM; - goto nodev; + goto free_netdev; } + /* Setup checksum offload, but default to off if not specified */ lp->features = 0; @@ -1580,17 +1583,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"); - ret = -ENODEV; - 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); @@ -1598,7 +1605,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 */ @@ -1606,7 +1613,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); @@ -1614,27 +1621,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; } @@ -1649,9 +1652,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;