Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[patch] stmmac: use resource_size()

0 views
Skip to first unread message

Dan Carpenter

unread,
Mar 22, 2010, 8:20:02 AM3/22/10
to
The size calculation is not correct. It should be end - start + 1.
Use resource_size() to calculate it instead.

Signed-off-by: Dan Carpenter <err...@gmail.com>

diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index a673361..92bef30 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1685,8 +1685,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
}
pr_info("done!\n");

- if (!request_mem_region(res->start, (res->end - res->start),
- pdev->name)) {
+ if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
pr_err("%s: ERROR: memory allocation failed"
"cannot get the I/O addr 0x%x\n",
__func__, (unsigned int)res->start);
@@ -1694,9 +1693,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
goto out;
}

- addr = ioremap(res->start, (res->end - res->start));
+ addr = ioremap(res->start, resource_size(res));
if (!addr) {
- pr_err("%s: ERROR: memory mapping failed \n", __func__);
+ pr_err("%s: ERROR: memory mapping failed\n", __func__);
ret = -ENOMEM;
goto out;
}
@@ -1774,7 +1773,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
out:
if (ret < 0) {
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)
iounmap(addr);
}
@@ -1812,7 +1811,7 @@ static int stmmac_dvr_remove(struct platform_device *pdev)

iounmap((void *)ndev->base_addr);
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);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Giuseppe CAVALLARO

unread,
Mar 22, 2010, 11:50:02 AM3/22/10
to
Hi Dan
Thanks, the patch can also applied against the net-next driver and it's ok.

Regards,
Giuseppe

David Miller

unread,
Mar 22, 2010, 9:40:01 PM3/22/10
to
From: Giuseppe CAVALLARO <peppe.c...@st.com>
Date: Mon, 22 Mar 2010 16:15:03 +0100

> Hi Dan
> Thanks, the patch can also applied against the net-next driver and it's ok.

Applied, thanks everyone.

0 new messages