Commit 3f8bdecd authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by David S. Miller

net:stmmac: convert driver to use devm_request_and_ioremap.

This patch moves calls to ioremap and request_mem_region to
devm_request_and_ioremap call.
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d56631a6
...@@ -78,6 +78,7 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -78,6 +78,7 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev)
{ {
int ret = 0; int ret = 0;
struct resource *res; struct resource *res;
struct device *dev = &pdev->dev;
void __iomem *addr = NULL; void __iomem *addr = NULL;
struct stmmac_priv *priv = NULL; struct stmmac_priv *priv = NULL;
struct plat_stmmacenet_data *plat_dat = NULL; struct plat_stmmacenet_data *plat_dat = NULL;
...@@ -87,18 +88,10 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -87,18 +88,10 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev)
if (!res) if (!res)
return -ENODEV; return -ENODEV;
if (!request_mem_region(res->start, resource_size(res), pdev->name)) { addr = devm_request_and_ioremap(dev, res);
pr_err("%s: ERROR: memory allocation failed"
"cannot get the I/O addr 0x%x\n",
__func__, (unsigned int)res->start);
return -EBUSY;
}
addr = ioremap(res->start, resource_size(res));
if (!addr) { if (!addr) {
pr_err("%s: ERROR: memory mapping failed", __func__); pr_err("%s: ERROR: memory mapping failed", __func__);
ret = -ENOMEM; return -ENOMEM;
goto out_release_region;
} }
if (pdev->dev.of_node) { if (pdev->dev.of_node) {
...@@ -107,14 +100,13 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -107,14 +100,13 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev)
GFP_KERNEL); GFP_KERNEL);
if (!plat_dat) { if (!plat_dat) {
pr_err("%s: ERROR: no memory", __func__); pr_err("%s: ERROR: no memory", __func__);
ret = -ENOMEM; return -ENOMEM;
goto out_unmap;
} }
ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
if (ret) { if (ret) {
pr_err("%s: main dt probe failed", __func__); pr_err("%s: main dt probe failed", __func__);
goto out_unmap; return ret;
} }
} else { } else {
plat_dat = pdev->dev.platform_data; plat_dat = pdev->dev.platform_data;
...@@ -124,13 +116,13 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -124,13 +116,13 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev)
if (plat_dat->init) { if (plat_dat->init) {
ret = plat_dat->init(pdev); ret = plat_dat->init(pdev);
if (unlikely(ret)) if (unlikely(ret))
goto out_unmap; return ret;
} }
priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr); priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr);
if (!priv) { if (!priv) {
pr_err("%s: main driver probe failed", __func__); pr_err("%s: main driver probe failed", __func__);
goto out_unmap; return -ENODEV;
} }
/* Get MAC address if available (DT) */ /* Get MAC address if available (DT) */
...@@ -142,8 +134,7 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -142,8 +134,7 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev)
if (priv->dev->irq == -ENXIO) { if (priv->dev->irq == -ENXIO) {
pr_err("%s: ERROR: MAC IRQ configuration " pr_err("%s: ERROR: MAC IRQ configuration "
"information not found\n", __func__); "information not found\n", __func__);
ret = -ENXIO; return -ENXIO;
goto out_unmap;
} }
/* /*
...@@ -165,15 +156,6 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev) ...@@ -165,15 +156,6 @@ static int __devinit stmmac_pltfr_probe(struct platform_device *pdev)
pr_debug("STMMAC platform driver registration completed"); pr_debug("STMMAC platform driver registration completed");
return 0; return 0;
out_unmap:
iounmap(addr);
platform_set_drvdata(pdev, NULL);
out_release_region:
release_mem_region(res->start, resource_size(res));
return ret;
} }
/** /**
...@@ -186,8 +168,6 @@ static int stmmac_pltfr_remove(struct platform_device *pdev) ...@@ -186,8 +168,6 @@ static int stmmac_pltfr_remove(struct platform_device *pdev)
{ {
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
struct stmmac_priv *priv = netdev_priv(ndev); struct stmmac_priv *priv = netdev_priv(ndev);
void __iomem *addr = priv->ioaddr;
struct resource *res;
int ret = stmmac_dvr_remove(ndev); int ret = stmmac_dvr_remove(ndev);
if (priv->plat->exit) if (priv->plat->exit)
...@@ -195,10 +175,6 @@ static int stmmac_pltfr_remove(struct platform_device *pdev) ...@@ -195,10 +175,6 @@ static int stmmac_pltfr_remove(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
iounmap(addr);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));
return ret; return ret;
} }
......
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