linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: michal.simek@xilinx.com (Michal Simek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 11/14] net: axienet: Use devm_* calls
Date: Wed, 12 Feb 2014 16:55:45 +0100	[thread overview]
Message-ID: <1b09a985cd055344d7ff874eb27b30c9c3b27c6a.1392220536.git.michal.simek@xilinx.com> (raw)
In-Reply-To: <cover.1392220536.git.michal.simek@xilinx.com>

From: Srikanth Thokala <srikanth.thokala@xilinx.com>

use devm_* calls

Signed-off-by: Srikanth Thokala <sthokal@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 54 ++++++++++++-----------
 1 file changed, 28 insertions(+), 26 deletions(-)

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;
--
1.8.2.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140212/7b8a2828/attachment-0001.sig>

  parent reply	other threads:[~2014-02-12 15:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12 15:55 [PATCH 0/14] Xilinx axi ethernet patches Michal Simek
2014-02-12 15:55 ` [PATCH 01/14] net: axienet: Fix compilation error Michal Simek
2014-02-12 15:55 ` [PATCH 02/14] net: axienet: Fix compilation warnings Michal Simek
2014-02-12 15:55 ` [PATCH 03/14] net: axienet: Support for RGMII Michal Simek
2014-02-12 15:55 ` [PATCH 04/14] net: axienet: Handle 0 packet receive gracefully Michal Simek
2014-02-12 15:55 ` [PATCH 05/14] net: axienet: Service completion interrupts ASAP Michal Simek
2014-02-12 16:38   ` David Laight
2014-02-12 15:55 ` [PATCH 06/14] net: axienet: Handle jumbo frames for lesser frame sizes Michal Simek
2014-02-12 15:55 ` [PATCH 07/14] net: axienet: Support phy-less mode of operation Michal Simek
2014-02-12 15:55 ` [PATCH 08/14] net: axienet: Removed checkpatch errors/warnings Michal Simek
2014-02-13  0:31   ` Joe Perches
2014-02-13  7:19     ` Michal Simek
2014-02-13 15:51       ` Joe Perches
2014-02-14  9:21         ` Michal Simek
2014-02-12 15:55 ` [PATCH 09/14] net: axienet: Fix comments blocks Michal Simek
2014-02-12 15:55 ` [PATCH 10/14] net: axienet: Use pdev instead of op Michal Simek
2014-02-12 15:55 ` Michal Simek [this message]
2014-02-12 15:55 ` [PATCH 12/14] net: axienet: Use of_property_* calls Michal Simek
2014-02-12 15:55 ` [PATCH 13/14] net: axienet: Removed _of_ prefix in probe and remove functions Michal Simek
2014-02-12 15:55 ` [PATCH 14/14] net: axienet: Fix kernel-doc warnings Michal Simek
2014-02-13  0:18 ` [PATCH 0/14] Xilinx axi ethernet patches David Miller
2014-02-13  7:00   ` Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1b09a985cd055344d7ff874eb27b30c9c3b27c6a.1392220536.git.michal.simek@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).