netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] stmmac: use resource_size()
@ 2010-03-22 12:11 Dan Carpenter
  2010-03-22 15:15 ` Giuseppe CAVALLARO
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2010-03-22 12:11 UTC (permalink / raw)
  To: netdev
  Cc: Giuseppe Cavallaro, Joe Perches, linux-kernel, kernel-janitors,
	David S. Miller

The size calculation is not correct.  It should be end - start + 1.
Use resource_size() to calculate it instead.

Signed-off-by: Dan Carpenter <error27@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);
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] stmmac: use resource_size()
  2010-03-22 12:11 [patch] stmmac: use resource_size() Dan Carpenter
@ 2010-03-22 15:15 ` Giuseppe CAVALLARO
  2010-03-23  1:33   ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Giuseppe CAVALLARO @ 2010-03-22 15:15 UTC (permalink / raw)
  To: Dan Carpenter, netdev, Joe Perches, linux-kernel, kernel-janitors,
	David S. Miller

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

Regards,
 Giuseppe

Dan Carpenter wrote:
> The size calculation is not correct.  It should be end - start + 1.
> Use resource_size() to calculate it instead.
> 
> Signed-off-by: Dan Carpenter <error27@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);
>  
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] stmmac: use resource_size()
  2010-03-22 15:15 ` Giuseppe CAVALLARO
@ 2010-03-23  1:33   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2010-03-23  1:33 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: error27, netdev, joe, linux-kernel, kernel-janitors

From: Giuseppe CAVALLARO <peppe.cavallaro@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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch] stmmac: use resource_size()
@ 2010-04-07  9:35 Dan Carpenter
  2010-04-08  4:50 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2010-04-07  9:35 UTC (permalink / raw)
  To: Giuseppe Cavallaro
  Cc: Joe Perches, Tejun Heo, Christoph Lameter, netdev,
	kernel-janitors, David S. Miller

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: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index a214a16..4111a85 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1686,7 +1686,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
 	}
 	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)) {
 		pr_err("%s: ERROR: memory allocation failed"
 		       "cannot get the I/O addr 0x%x\n",
@@ -1695,9 +1695,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;
 	}
@@ -1775,7 +1775,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);
 	}
@@ -1813,7 +1813,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);
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] stmmac: use resource_size()
  2010-04-07  9:35 Dan Carpenter
@ 2010-04-08  4:50 ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2010-04-08  4:50 UTC (permalink / raw)
  To: error27; +Cc: peppe.cavallaro, joe, tj, cl, netdev, kernel-janitors

From: Dan Carpenter <error27@gmail.com>
Date: Wed, 7 Apr 2010 12:35:46 +0300

> 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: Dan Carpenter <error27@gmail.com>

Applied, thanks Dan.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-04-08  4:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-22 12:11 [patch] stmmac: use resource_size() Dan Carpenter
2010-03-22 15:15 ` Giuseppe CAVALLARO
2010-03-23  1:33   ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2010-04-07  9:35 Dan Carpenter
2010-04-08  4:50 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).