diff options
| author | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2014-03-27 06:39:29 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-03-29 15:31:33 -0400 |
| commit | c3f0dd38996d5f4e7c681099ba18cc1587155edb (patch) | |
| tree | 5c5f032bebb956475aa21fabf138da46f66c390b | |
| parent | 015f0688f57ca4d499047d335b8052a733e17a4d (diff) | |
net: mvneta: use devm_ioremap_resource() instead of of_iomap()
The mvneta driver currently uses of_iomap(), which has two drawbacks:
it doesn't request the resource, and it isn't devm-style so some error
handling is needed.
This commit switches to use devm_ioremap_resource() instead, which
automatically requests the resource (so the I/O registers region shows
up properly in /proc/iomem), and also is devm-style, which allows to
get rid of some error handling to unmap the I/O registers region.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/marvell/mvneta.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index f3afcbdbb725..bcce0b437722 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
| 23 | #include <net/ip.h> | 23 | #include <net/ip.h> |
| 24 | #include <net/ipv6.h> | 24 | #include <net/ipv6.h> |
| 25 | #include <linux/io.h> | ||
| 25 | #include <linux/of.h> | 26 | #include <linux/of.h> |
| 26 | #include <linux/of_irq.h> | 27 | #include <linux/of_irq.h> |
| 27 | #include <linux/of_mdio.h> | 28 | #include <linux/of_mdio.h> |
| @@ -2774,6 +2775,7 @@ static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode) | |||
| 2774 | static int mvneta_probe(struct platform_device *pdev) | 2775 | static int mvneta_probe(struct platform_device *pdev) |
| 2775 | { | 2776 | { |
| 2776 | const struct mbus_dram_target_info *dram_target_info; | 2777 | const struct mbus_dram_target_info *dram_target_info; |
| 2778 | struct resource *res; | ||
| 2777 | struct device_node *dn = pdev->dev.of_node; | 2779 | struct device_node *dn = pdev->dev.of_node; |
| 2778 | struct device_node *phy_node; | 2780 | struct device_node *phy_node; |
| 2779 | u32 phy_addr; | 2781 | u32 phy_addr; |
| @@ -2837,9 +2839,10 @@ static int mvneta_probe(struct platform_device *pdev) | |||
| 2837 | 2839 | ||
| 2838 | clk_prepare_enable(pp->clk); | 2840 | clk_prepare_enable(pp->clk); |
| 2839 | 2841 | ||
| 2840 | pp->base = of_iomap(dn, 0); | 2842 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 2841 | if (pp->base == NULL) { | 2843 | pp->base = devm_ioremap_resource(&pdev->dev, res); |
| 2842 | err = -ENOMEM; | 2844 | if (IS_ERR(pp->base)) { |
| 2845 | err = PTR_ERR(pp->base); | ||
| 2843 | goto err_clk; | 2846 | goto err_clk; |
| 2844 | } | 2847 | } |
| 2845 | 2848 | ||
| @@ -2847,7 +2850,7 @@ static int mvneta_probe(struct platform_device *pdev) | |||
| 2847 | pp->stats = netdev_alloc_pcpu_stats(struct mvneta_pcpu_stats); | 2850 | pp->stats = netdev_alloc_pcpu_stats(struct mvneta_pcpu_stats); |
| 2848 | if (!pp->stats) { | 2851 | if (!pp->stats) { |
| 2849 | err = -ENOMEM; | 2852 | err = -ENOMEM; |
| 2850 | goto err_unmap; | 2853 | goto err_clk; |
| 2851 | } | 2854 | } |
| 2852 | 2855 | ||
| 2853 | dt_mac_addr = of_get_mac_address(dn); | 2856 | dt_mac_addr = of_get_mac_address(dn); |
| @@ -2906,8 +2909,6 @@ err_deinit: | |||
| 2906 | mvneta_deinit(pp); | 2909 | mvneta_deinit(pp); |
| 2907 | err_free_stats: | 2910 | err_free_stats: |
| 2908 | free_percpu(pp->stats); | 2911 | free_percpu(pp->stats); |
| 2909 | err_unmap: | ||
| 2910 | iounmap(pp->base); | ||
| 2911 | err_clk: | 2912 | err_clk: |
| 2912 | clk_disable_unprepare(pp->clk); | 2913 | clk_disable_unprepare(pp->clk); |
| 2913 | err_free_irq: | 2914 | err_free_irq: |
| @@ -2927,7 +2928,6 @@ static int mvneta_remove(struct platform_device *pdev) | |||
| 2927 | mvneta_deinit(pp); | 2928 | mvneta_deinit(pp); |
| 2928 | clk_disable_unprepare(pp->clk); | 2929 | clk_disable_unprepare(pp->clk); |
| 2929 | free_percpu(pp->stats); | 2930 | free_percpu(pp->stats); |
| 2930 | iounmap(pp->base); | ||
| 2931 | irq_dispose_mapping(dev->irq); | 2931 | irq_dispose_mapping(dev->irq); |
| 2932 | free_netdev(dev); | 2932 | free_netdev(dev); |
| 2933 | 2933 | ||
