diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2013-03-11 03:32:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-12 08:04:09 -0400 |
commit | 83e519b63480e691d43ee106547b10941bfa0232 (patch) | |
tree | 94420d0bcb206b2e762b0f69d4a97c64a3e3dcee | |
parent | a2e4b59a71d9178f68a970ee423cbde68b70fa74 (diff) |
fec: Use devm_request_and_ioremap()
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>
-rw-r--r-- | drivers/net/ethernet/freescale/fec.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c index 46e6bc0150ea..e6224949891f 100644 --- a/drivers/net/ethernet/freescale/fec.c +++ b/drivers/net/ethernet/freescale/fec.c | |||
@@ -1731,16 +1731,10 @@ fec_probe(struct platform_device *pdev) | |||
1731 | if (!r) | 1731 | if (!r) |
1732 | return -ENXIO; | 1732 | return -ENXIO; |
1733 | 1733 | ||
1734 | r = request_mem_region(r->start, resource_size(r), pdev->name); | ||
1735 | if (!r) | ||
1736 | return -EBUSY; | ||
1737 | |||
1738 | /* Init network device */ | 1734 | /* Init network device */ |
1739 | ndev = alloc_etherdev(sizeof(struct fec_enet_private)); | 1735 | ndev = alloc_etherdev(sizeof(struct fec_enet_private)); |
1740 | if (!ndev) { | 1736 | if (!ndev) |
1741 | ret = -ENOMEM; | 1737 | return -ENOMEM; |
1742 | goto failed_alloc_etherdev; | ||
1743 | } | ||
1744 | 1738 | ||
1745 | SET_NETDEV_DEV(ndev, &pdev->dev); | 1739 | SET_NETDEV_DEV(ndev, &pdev->dev); |
1746 | 1740 | ||
@@ -1752,7 +1746,7 @@ fec_probe(struct platform_device *pdev) | |||
1752 | (pdev->id_entry->driver_data & FEC_QUIRK_HAS_GBIT)) | 1746 | (pdev->id_entry->driver_data & FEC_QUIRK_HAS_GBIT)) |
1753 | fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG; | 1747 | fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG; |
1754 | 1748 | ||
1755 | fep->hwp = ioremap(r->start, resource_size(r)); | 1749 | fep->hwp = devm_request_and_ioremap(&pdev->dev, r); |
1756 | fep->pdev = pdev; | 1750 | fep->pdev = pdev; |
1757 | fep->dev_id = dev_id++; | 1751 | fep->dev_id = dev_id++; |
1758 | 1752 | ||
@@ -1874,11 +1868,8 @@ failed_regulator: | |||
1874 | clk_disable_unprepare(fep->clk_ptp); | 1868 | clk_disable_unprepare(fep->clk_ptp); |
1875 | failed_pin: | 1869 | failed_pin: |
1876 | failed_clk: | 1870 | failed_clk: |
1877 | iounmap(fep->hwp); | ||
1878 | failed_ioremap: | 1871 | failed_ioremap: |
1879 | free_netdev(ndev); | 1872 | free_netdev(ndev); |
1880 | failed_alloc_etherdev: | ||
1881 | release_mem_region(r->start, resource_size(r)); | ||
1882 | 1873 | ||
1883 | return ret; | 1874 | return ret; |
1884 | } | 1875 | } |
@@ -1888,7 +1879,6 @@ fec_drv_remove(struct platform_device *pdev) | |||
1888 | { | 1879 | { |
1889 | struct net_device *ndev = platform_get_drvdata(pdev); | 1880 | struct net_device *ndev = platform_get_drvdata(pdev); |
1890 | struct fec_enet_private *fep = netdev_priv(ndev); | 1881 | struct fec_enet_private *fep = netdev_priv(ndev); |
1891 | struct resource *r; | ||
1892 | int i; | 1882 | int i; |
1893 | 1883 | ||
1894 | unregister_netdev(ndev); | 1884 | unregister_netdev(ndev); |
@@ -1904,13 +1894,8 @@ fec_drv_remove(struct platform_device *pdev) | |||
1904 | if (irq > 0) | 1894 | if (irq > 0) |
1905 | free_irq(irq, ndev); | 1895 | free_irq(irq, ndev); |
1906 | } | 1896 | } |
1907 | iounmap(fep->hwp); | ||
1908 | free_netdev(ndev); | 1897 | free_netdev(ndev); |
1909 | 1898 | ||
1910 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1911 | BUG_ON(!r); | ||
1912 | release_mem_region(r->start, resource_size(r)); | ||
1913 | |||
1914 | platform_set_drvdata(pdev, NULL); | 1899 | platform_set_drvdata(pdev, NULL); |
1915 | 1900 | ||
1916 | return 0; | 1901 | return 0; |