fec: Use devm_request_and_ioremap()
authorFabio Estevam <fabio.estevam@freescale.com>
Mon, 11 Mar 2013 07:32:55 +0000 (07:32 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Mar 2013 12:04:09 +0000 (08:04 -0400)
Using devm_request_and_ioremap() can make the code cleaner and simpler.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/fec.c

index 46e6bc0150ea896aed876268c04f899323348611..e6224949891f6a174b02d624cbffe474eac8e2e9 100644 (file)
@@ -1731,16 +1731,10 @@ fec_probe(struct platform_device *pdev)
        if (!r)
                return -ENXIO;
 
-       r = request_mem_region(r->start, resource_size(r), pdev->name);
-       if (!r)
-               return -EBUSY;
-
        /* Init network device */
        ndev = alloc_etherdev(sizeof(struct fec_enet_private));
-       if (!ndev) {
-               ret = -ENOMEM;
-               goto failed_alloc_etherdev;
-       }
+       if (!ndev)
+               return -ENOMEM;
 
        SET_NETDEV_DEV(ndev, &pdev->dev);
 
@@ -1752,7 +1746,7 @@ fec_probe(struct platform_device *pdev)
            (pdev->id_entry->driver_data & FEC_QUIRK_HAS_GBIT))
                fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG;
 
-       fep->hwp = ioremap(r->start, resource_size(r));
+       fep->hwp = devm_request_and_ioremap(&pdev->dev, r);
        fep->pdev = pdev;
        fep->dev_id = dev_id++;
 
@@ -1874,11 +1868,8 @@ failed_regulator:
                clk_disable_unprepare(fep->clk_ptp);
 failed_pin:
 failed_clk:
-       iounmap(fep->hwp);
 failed_ioremap:
        free_netdev(ndev);
-failed_alloc_etherdev:
-       release_mem_region(r->start, resource_size(r));
 
        return ret;
 }
@@ -1888,7 +1879,6 @@ fec_drv_remove(struct platform_device *pdev)
 {
        struct net_device *ndev = platform_get_drvdata(pdev);
        struct fec_enet_private *fep = netdev_priv(ndev);
-       struct resource *r;
        int i;
 
        unregister_netdev(ndev);
@@ -1904,13 +1894,8 @@ fec_drv_remove(struct platform_device *pdev)
                if (irq > 0)
                        free_irq(irq, ndev);
        }
-       iounmap(fep->hwp);
        free_netdev(ndev);
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       BUG_ON(!r);
-       release_mem_region(r->start, resource_size(r));
-
        platform_set_drvdata(pdev, NULL);
 
        return 0;