Commit 1c03da05 authored by Jonas Gorski's avatar Jonas Gorski Committed by David S. Miller

bcm63xx_enet: use managed io memory allocations

Signed-off-by: default avatarJonas Gorski <jogo@openwrt.org>
Acked-by: default avatarKevin Cernekee <cernekee@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e41eef8f
...@@ -1619,7 +1619,6 @@ static int bcm_enet_probe(struct platform_device *pdev) ...@@ -1619,7 +1619,6 @@ static int bcm_enet_probe(struct platform_device *pdev)
struct resource *res_mem, *res_irq, *res_irq_rx, *res_irq_tx; struct resource *res_mem, *res_irq, *res_irq_rx, *res_irq_tx;
struct mii_bus *bus; struct mii_bus *bus;
const char *clk_name; const char *clk_name;
unsigned int iomem_size;
int i, ret; int i, ret;
/* stop if shared driver failed, assume driver->probe will be /* stop if shared driver failed, assume driver->probe will be
...@@ -1644,17 +1643,12 @@ static int bcm_enet_probe(struct platform_device *pdev) ...@@ -1644,17 +1643,12 @@ static int bcm_enet_probe(struct platform_device *pdev)
if (ret) if (ret)
goto out; goto out;
iomem_size = resource_size(res_mem); priv->base = devm_request_and_ioremap(&pdev->dev, res_mem);
if (!request_mem_region(res_mem->start, iomem_size, "bcm63xx_enet")) {
ret = -EBUSY;
goto out;
}
priv->base = ioremap(res_mem->start, iomem_size);
if (priv->base == NULL) { if (priv->base == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_release_mem; goto out;
} }
dev->irq = priv->irq = res_irq->start; dev->irq = priv->irq = res_irq->start;
priv->irq_rx = res_irq_rx->start; priv->irq_rx = res_irq_rx->start;
priv->irq_tx = res_irq_tx->start; priv->irq_tx = res_irq_tx->start;
...@@ -1674,7 +1668,7 @@ static int bcm_enet_probe(struct platform_device *pdev) ...@@ -1674,7 +1668,7 @@ static int bcm_enet_probe(struct platform_device *pdev)
priv->mac_clk = clk_get(&pdev->dev, clk_name); priv->mac_clk = clk_get(&pdev->dev, clk_name);
if (IS_ERR(priv->mac_clk)) { if (IS_ERR(priv->mac_clk)) {
ret = PTR_ERR(priv->mac_clk); ret = PTR_ERR(priv->mac_clk);
goto out_unmap; goto out;
} }
clk_enable(priv->mac_clk); clk_enable(priv->mac_clk);
...@@ -1814,12 +1808,6 @@ static int bcm_enet_probe(struct platform_device *pdev) ...@@ -1814,12 +1808,6 @@ static int bcm_enet_probe(struct platform_device *pdev)
out_put_clk_mac: out_put_clk_mac:
clk_disable(priv->mac_clk); clk_disable(priv->mac_clk);
clk_put(priv->mac_clk); clk_put(priv->mac_clk);
out_unmap:
iounmap(priv->base);
out_release_mem:
release_mem_region(res_mem->start, iomem_size);
out: out:
free_netdev(dev); free_netdev(dev);
return ret; return ret;
...@@ -1833,7 +1821,6 @@ static int bcm_enet_remove(struct platform_device *pdev) ...@@ -1833,7 +1821,6 @@ static int bcm_enet_remove(struct platform_device *pdev)
{ {
struct bcm_enet_priv *priv; struct bcm_enet_priv *priv;
struct net_device *dev; struct net_device *dev;
struct resource *res;
/* stop netdevice */ /* stop netdevice */
dev = platform_get_drvdata(pdev); dev = platform_get_drvdata(pdev);
...@@ -1856,11 +1843,6 @@ static int bcm_enet_remove(struct platform_device *pdev) ...@@ -1856,11 +1843,6 @@ static int bcm_enet_remove(struct platform_device *pdev)
bcm_enet_mdio_write_mii); bcm_enet_mdio_write_mii);
} }
/* release device resources */
iounmap(priv->base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));
/* disable hw block clocks */ /* disable hw block clocks */
if (priv->phy_clk) { if (priv->phy_clk) {
clk_disable(priv->phy_clk); clk_disable(priv->phy_clk);
...@@ -1889,31 +1871,20 @@ struct platform_driver bcm63xx_enet_driver = { ...@@ -1889,31 +1871,20 @@ struct platform_driver bcm63xx_enet_driver = {
static int bcm_enet_shared_probe(struct platform_device *pdev) static int bcm_enet_shared_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res;
unsigned int iomem_size;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) if (!res)
return -ENODEV; return -ENODEV;
iomem_size = resource_size(res); bcm_enet_shared_base = devm_request_and_ioremap(&pdev->dev, res);
if (!request_mem_region(res->start, iomem_size, "bcm63xx_enet_dma")) if (!bcm_enet_shared_base)
return -EBUSY;
bcm_enet_shared_base = ioremap(res->start, iomem_size);
if (!bcm_enet_shared_base) {
release_mem_region(res->start, iomem_size);
return -ENOMEM; return -ENOMEM;
}
return 0; return 0;
} }
static int bcm_enet_shared_remove(struct platform_device *pdev) static int bcm_enet_shared_remove(struct platform_device *pdev)
{ {
struct resource *res;
iounmap(bcm_enet_shared_base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));
return 0; return 0;
} }
......
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