Commit c3f0dd38 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by David S. Miller

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: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 015f0688
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/ipv6.h> #include <net/ipv6.h>
#include <linux/io.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
...@@ -2774,6 +2775,7 @@ static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode) ...@@ -2774,6 +2775,7 @@ static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
static int mvneta_probe(struct platform_device *pdev) static int mvneta_probe(struct platform_device *pdev)
{ {
const struct mbus_dram_target_info *dram_target_info; const struct mbus_dram_target_info *dram_target_info;
struct resource *res;
struct device_node *dn = pdev->dev.of_node; struct device_node *dn = pdev->dev.of_node;
struct device_node *phy_node; struct device_node *phy_node;
u32 phy_addr; u32 phy_addr;
...@@ -2837,9 +2839,10 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -2837,9 +2839,10 @@ static int mvneta_probe(struct platform_device *pdev)
clk_prepare_enable(pp->clk); clk_prepare_enable(pp->clk);
pp->base = of_iomap(dn, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (pp->base == NULL) { pp->base = devm_ioremap_resource(&pdev->dev, res);
err = -ENOMEM; if (IS_ERR(pp->base)) {
err = PTR_ERR(pp->base);
goto err_clk; goto err_clk;
} }
...@@ -2847,7 +2850,7 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -2847,7 +2850,7 @@ static int mvneta_probe(struct platform_device *pdev)
pp->stats = netdev_alloc_pcpu_stats(struct mvneta_pcpu_stats); pp->stats = netdev_alloc_pcpu_stats(struct mvneta_pcpu_stats);
if (!pp->stats) { if (!pp->stats) {
err = -ENOMEM; err = -ENOMEM;
goto err_unmap; goto err_clk;
} }
dt_mac_addr = of_get_mac_address(dn); dt_mac_addr = of_get_mac_address(dn);
...@@ -2906,8 +2909,6 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -2906,8 +2909,6 @@ static int mvneta_probe(struct platform_device *pdev)
mvneta_deinit(pp); mvneta_deinit(pp);
err_free_stats: err_free_stats:
free_percpu(pp->stats); free_percpu(pp->stats);
err_unmap:
iounmap(pp->base);
err_clk: err_clk:
clk_disable_unprepare(pp->clk); clk_disable_unprepare(pp->clk);
err_free_irq: err_free_irq:
...@@ -2927,7 +2928,6 @@ static int mvneta_remove(struct platform_device *pdev) ...@@ -2927,7 +2928,6 @@ static int mvneta_remove(struct platform_device *pdev)
mvneta_deinit(pp); mvneta_deinit(pp);
clk_disable_unprepare(pp->clk); clk_disable_unprepare(pp->clk);
free_percpu(pp->stats); free_percpu(pp->stats);
iounmap(pp->base);
irq_dispose_mapping(dev->irq); irq_dispose_mapping(dev->irq);
free_netdev(dev); free_netdev(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment