Commit b6222682 authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller

stmmac: use resource_size()

Resource size should be calculated as end - start + 1 because we start
counting at zero.  I changed the code to resource_size() to do the 
calculation.
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ddd0451f
...@@ -1685,7 +1685,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev) ...@@ -1685,7 +1685,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
} }
pr_info("done!\n"); pr_info("done!\n");
if (!request_mem_region(res->start, (res->end - res->start), if (!request_mem_region(res->start, resource_size(res),
pdev->name)) { pdev->name)) {
pr_err("%s: ERROR: memory allocation failed" pr_err("%s: ERROR: memory allocation failed"
"cannot get the I/O addr 0x%x\n", "cannot get the I/O addr 0x%x\n",
...@@ -1694,9 +1694,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev) ...@@ -1694,9 +1694,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
goto out; goto out;
} }
addr = ioremap(res->start, (res->end - res->start)); addr = ioremap(res->start, resource_size(res));
if (!addr) { if (!addr) {
pr_err("%s: ERROR: memory mapping failed \n", __func__); pr_err("%s: ERROR: memory mapping failed\n", __func__);
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
...@@ -1774,7 +1774,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev) ...@@ -1774,7 +1774,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
out: out:
if (ret < 0) { if (ret < 0) {
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
release_mem_region(res->start, (res->end - res->start)); release_mem_region(res->start, resource_size(res));
if (addr != NULL) if (addr != NULL)
iounmap(addr); iounmap(addr);
} }
...@@ -1812,7 +1812,7 @@ static int stmmac_dvr_remove(struct platform_device *pdev) ...@@ -1812,7 +1812,7 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
iounmap((void *)ndev->base_addr); iounmap((void *)ndev->base_addr);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, (res->end - res->start)); release_mem_region(res->start, resource_size(res));
free_netdev(ndev); free_netdev(ndev);
......
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