aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Petazzoni2014-03-25 18:26:55 -0500
committerDavid S. Miller2014-03-26 15:52:42 -0500
commitb5f3b75d9d3b5526d973fc0bfee5680bdc6acf2a (patch)
treeb2acdc5f918c94602776b1ad3cd05d075b625096
parente3a8786c10e75903f1269474e21fe8cb49c3a670 (diff)
downloadkernel-common-b5f3b75d9d3b5526d973fc0bfee5680bdc6acf2a.tar.gz
kernel-common-b5f3b75d9d3b5526d973fc0bfee5680bdc6acf2a.tar.xz
kernel-common-b5f3b75d9d3b5526d973fc0bfee5680bdc6acf2a.zip
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.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index c9c2faaf967..8d76fca7fde 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>
@@ -2749,6 +2750,7 @@ static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
2749static int mvneta_probe(struct platform_device *pdev) 2750static int mvneta_probe(struct platform_device *pdev)
2750{ 2751{
2751 const struct mbus_dram_target_info *dram_target_info; 2752 const struct mbus_dram_target_info *dram_target_info;
2753 struct resource *res;
2752 struct device_node *dn = pdev->dev.of_node; 2754 struct device_node *dn = pdev->dev.of_node;
2753 struct device_node *phy_node; 2755 struct device_node *phy_node;
2754 u32 phy_addr; 2756 u32 phy_addr;
@@ -2813,9 +2815,15 @@ static int mvneta_probe(struct platform_device *pdev)
2813 2815
2814 clk_prepare_enable(pp->clk); 2816 clk_prepare_enable(pp->clk);
2815 2817
2816 pp->base = of_iomap(dn, 0); 2818 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2819 if (!res) {
2820 err = -ENODEV;
2821 goto err_clk;
2822 }
2823
2824 pp->base = devm_ioremap_resource(&pdev->dev, res);
2817 if (pp->base == NULL) { 2825 if (pp->base == NULL) {
2818 err = -ENOMEM; 2826 err = PTR_ERR(pp->base);
2819 goto err_clk; 2827 goto err_clk;
2820 } 2828 }
2821 2829
@@ -2823,7 +2831,7 @@ static int mvneta_probe(struct platform_device *pdev)
2823 pp->stats = alloc_percpu(struct mvneta_pcpu_stats); 2831 pp->stats = alloc_percpu(struct mvneta_pcpu_stats);
2824 if (!pp->stats) { 2832 if (!pp->stats) {
2825 err = -ENOMEM; 2833 err = -ENOMEM;
2826 goto err_unmap; 2834 goto err_clk;
2827 } 2835 }
2828 2836
2829 for_each_possible_cpu(cpu) { 2837 for_each_possible_cpu(cpu) {
@@ -2888,8 +2896,6 @@ err_deinit:
2888 mvneta_deinit(pp); 2896 mvneta_deinit(pp);
2889err_free_stats: 2897err_free_stats:
2890 free_percpu(pp->stats); 2898 free_percpu(pp->stats);
2891err_unmap:
2892 iounmap(pp->base);
2893err_clk: 2899err_clk:
2894 clk_disable_unprepare(pp->clk); 2900 clk_disable_unprepare(pp->clk);
2895err_free_irq: 2901err_free_irq:
@@ -2909,7 +2915,6 @@ static int mvneta_remove(struct platform_device *pdev)
2909 mvneta_deinit(pp); 2915 mvneta_deinit(pp);
2910 clk_disable_unprepare(pp->clk); 2916 clk_disable_unprepare(pp->clk);
2911 free_percpu(pp->stats); 2917 free_percpu(pp->stats);
2912 iounmap(pp->base);
2913 irq_dispose_mapping(dev->irq); 2918 irq_dispose_mapping(dev->irq);
2914 free_netdev(dev); 2919 free_netdev(dev);
2915 2920