linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Use resource_size instead of computation
@ 2014-05-28 15:14 Benoit Taine
  2014-05-28 15:14 ` [PATCH 1/2] ALSA: au1x00: " Benoit Taine
  2014-05-28 15:14 ` [PATCH 2/2] lpc_eth: " Benoit Taine
  0 siblings, 2 replies; 12+ messages in thread
From: Benoit Taine @ 2014-05-28 15:14 UTC (permalink / raw)
  To: kernel-janitors; +Cc: benoit.taine, linux-kernel, netdev, alsa-devel

These patches enhance kernel style usage, and make use of the
resource_size() function instead of explicit computation.

The semantic patch at scripts/coccinelle/api/resource_size.cocci was
used to detect and edit this situation.

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

* [PATCH 1/2] ALSA: au1x00: Use resource_size instead of computation
  2014-05-28 15:14 [PATCH 0/2] Use resource_size instead of computation Benoit Taine
@ 2014-05-28 15:14 ` Benoit Taine
  2014-05-28 15:51   ` Takashi Iwai
  2014-05-28 15:14 ` [PATCH 2/2] lpc_eth: " Benoit Taine
  1 sibling, 1 reply; 12+ messages in thread
From: Benoit Taine @ 2014-05-28 15:14 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: benoit.taine, Takashi Iwai, alsa-devel, linux-kernel, kernel-janitors

This issue was reported by coccicheck using the semantic patch 
at scripts/coccinelle/api/resource_size.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested, due incompatible architecture.

 sound/mips/au1x00.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
index d10ef76..fbcaa54 100644
--- a/sound/mips/au1x00.c
+++ b/sound/mips/au1x00.c
@@ -648,14 +648,14 @@ static int au1000_ac97_probe(struct platform_device *pdev)
 		goto out;
 
 	err = -EBUSY;
-	au1000->ac97_res_port = request_mem_region(r->start,
-					r->end - r->start + 1, pdev->name);
+	au1000->ac97_res_port = request_mem_region(r->start, resource_size(r),
+						   pdev->name);
 	if (!au1000->ac97_res_port) {
 		snd_printk(KERN_ERR "ALSA AC97: can't grab AC97 port\n");
 		goto out;
 	}
 
-	io = ioremap(r->start, r->end - r->start + 1);
+	io = ioremap(r->start, resource_size(r));
 	if (!io)
 		goto out;
 


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

* [PATCH 2/2] lpc_eth: Use resource_size instead of computation
  2014-05-28 15:14 [PATCH 0/2] Use resource_size instead of computation Benoit Taine
  2014-05-28 15:14 ` [PATCH 1/2] ALSA: au1x00: " Benoit Taine
@ 2014-05-28 15:14 ` Benoit Taine
  2014-05-28 16:16   ` Joe Perches
  2014-06-02  2:27   ` David Miller
  1 sibling, 2 replies; 12+ messages in thread
From: Benoit Taine @ 2014-05-28 15:14 UTC (permalink / raw)
  To: netdev; +Cc: benoit.taine, linux-kernel, kernel-janitors

This issue was reported by coccicheck using the semantic patch 
at scripts/coccinelle/api/resource_size.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested, due incompatible architecture.

 drivers/net/ethernet/nxp/lpc_eth.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 422d9b5..dc2f15c 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1361,7 +1361,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
 	__lpc_eth_clock_enable(pldat, true);
 
 	/* Map IO space */
-	pldat->net_base = ioremap(res->start, res->end - res->start + 1);
+	pldat->net_base = ioremap(res->start, resource_size(res));
 	if (!pldat->net_base) {
 		dev_err(&pdev->dev, "failed to map registers\n");
 		ret = -ENOMEM;
@@ -1419,8 +1419,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
 
 	netdev_dbg(ndev, "IO address start     :0x%08x\n",
 			res->start);
-	netdev_dbg(ndev, "IO address size      :%d\n",
-			res->end - res->start + 1);
+	netdev_dbg(ndev, "IO address size      :%d\n", resource_size(res));
 	netdev_dbg(ndev, "IO address (mapped)  :0x%p\n",
 			pldat->net_base);
 	netdev_dbg(ndev, "IRQ number           :%d\n", ndev->irq);


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

* Re: [PATCH 1/2] ALSA: au1x00: Use resource_size instead of computation
  2014-05-28 15:14 ` [PATCH 1/2] ALSA: au1x00: " Benoit Taine
@ 2014-05-28 15:51   ` Takashi Iwai
  0 siblings, 0 replies; 12+ messages in thread
From: Takashi Iwai @ 2014-05-28 15:51 UTC (permalink / raw)
  To: Benoit Taine; +Cc: Jaroslav Kysela, alsa-devel, linux-kernel, kernel-janitors

At Wed, 28 May 2014 17:14:06 +0200,
Benoit Taine wrote:
> 
> This issue was reported by coccicheck using the semantic patch 
> at scripts/coccinelle/api/resource_size.cocci
> 
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>

Applied, thanks.


Takashi

> ---
> Not compile tested, due incompatible architecture.
> 
>  sound/mips/au1x00.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
> index d10ef76..fbcaa54 100644
> --- a/sound/mips/au1x00.c
> +++ b/sound/mips/au1x00.c
> @@ -648,14 +648,14 @@ static int au1000_ac97_probe(struct platform_device *pdev)
>  		goto out;
>  
>  	err = -EBUSY;
> -	au1000->ac97_res_port = request_mem_region(r->start,
> -					r->end - r->start + 1, pdev->name);
> +	au1000->ac97_res_port = request_mem_region(r->start, resource_size(r),
> +						   pdev->name);
>  	if (!au1000->ac97_res_port) {
>  		snd_printk(KERN_ERR "ALSA AC97: can't grab AC97 port\n");
>  		goto out;
>  	}
>  
> -	io = ioremap(r->start, r->end - r->start + 1);
> +	io = ioremap(r->start, resource_size(r));
>  	if (!io)
>  		goto out;
>  
> 

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

* Re: [PATCH 2/2] lpc_eth: Use resource_size instead of computation
  2014-05-28 15:14 ` [PATCH 2/2] lpc_eth: " Benoit Taine
@ 2014-05-28 16:16   ` Joe Perches
  2014-06-02  2:27   ` David Miller
  1 sibling, 0 replies; 12+ messages in thread
From: Joe Perches @ 2014-05-28 16:16 UTC (permalink / raw)
  To: Benoit Taine; +Cc: netdev, linux-kernel, kernel-janitors

On Wed, 2014-05-28 at 17:14 +0200, Benoit Taine wrote:
> This issue was reported by coccicheck using the semantic patch 
> at scripts/coccinelle/api/resource_size.cocci

Slightly associated trivial note:

> diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
[]
> @@ -1419,8 +1419,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
>  
>  	netdev_dbg(ndev, "IO address start     :0x%08x\n",
>  			res->start);
> -	netdev_dbg(ndev, "IO address size      :%d\n",
> -			res->end - res->start + 1);
> +	netdev_dbg(ndev, "IO address size      :%d\n", resource_size(res));

May be better using:

	netdev_dbg(ndev, "IO                       :%pR\n", res)



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

* Re: [PATCH 2/2] lpc_eth: Use resource_size instead of computation
  2014-05-28 15:14 ` [PATCH 2/2] lpc_eth: " Benoit Taine
  2014-05-28 16:16   ` Joe Perches
@ 2014-06-02  2:27   ` David Miller
  2014-06-02 11:24     ` [PATCH 2/2 v2] " Benoit Taine
  1 sibling, 1 reply; 12+ messages in thread
From: David Miller @ 2014-06-02  2:27 UTC (permalink / raw)
  To: benoit.taine; +Cc: netdev, linux-kernel, kernel-janitors

From: Benoit Taine <benoit.taine@lip6.fr>
Date: Wed, 28 May 2014 17:14:07 +0200

> @@ -1419,8 +1419,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
>  
>  	netdev_dbg(ndev, "IO address start     :0x%08x\n",
>  			res->start);
> -	netdev_dbg(ndev, "IO address size      :%d\n",
> -			res->end - res->start + 1);
> +	netdev_dbg(ndev, "IO address size      :%d\n", resource_size(res));
>  	netdev_dbg(ndev, "IO address (mapped)  :0x%p\n",
>  			pldat->net_base);

Please replace all of this with %pR as suggested by Joe, thanks.

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

* [PATCH 2/2 v2] lpc_eth: Use resource_size instead of computation
  2014-06-02  2:27   ` David Miller
@ 2014-06-02 11:24     ` Benoit Taine
  2014-06-02 11:34       ` [PATCH 2/2 v3] " Benoit Taine
  0 siblings, 1 reply; 12+ messages in thread
From: Benoit Taine @ 2014-06-02 11:24 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel, kernel-janitors

This issue was reported by coccicheck using the semantic patch 
at scripts/coccinelle/api/resource_size.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested, due incompatible architecture.

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 422d9b5..645dac3 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1361,7 +1361,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
        __lpc_eth_clock_enable(pldat, true);
 
        /* Map IO space */
-       pldat->net_base = ioremap(res->start, res->end - res->start + 1);
+       pldat->net_base = ioremap(res->start, resource_size(res));
        if (!pldat->net_base) {
                dev_err(&pdev->dev, "failed to map registers\n");
                ret = -ENOMEM;
@@ -1417,10 +1417,8 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
        }
        pldat->dma_buff_base_p = dma_handle;
 
-       netdev_dbg(ndev, "IO address start     :0x%08x\n",
-                       res->start);
-       netdev_dbg(ndev, "IO address size      :%d\n",
-                       res->end - res->start + 1);
+       netdev_dbg(ndev, "IO address space     :%pR", res);
+       netdev_dbg(ndev, "IO address size      :%d\n", resource_size(res));
        netdev_dbg(ndev, "IO address (mapped)  :0x%p\n",
                        pldat->net_base);
        netdev_dbg(ndev, "IRQ number           :%d\n", ndev->irq);


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

* Re: [PATCH 2/2 v3] lpc_eth: Use resource_size instead of computation
  2014-06-02 11:24     ` [PATCH 2/2 v2] " Benoit Taine
@ 2014-06-02 11:34       ` Benoit Taine
  2014-06-02 17:58         ` David Miller
  2014-06-03 10:32         ` [PATCH 2/2 v4] " Benoit Taine
  0 siblings, 2 replies; 12+ messages in thread
From: Benoit Taine @ 2014-06-02 11:34 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel, kernel-janitors

This issue was reported by coccicheck using the semantic patch 
at scripts/coccinelle/api/resource_size.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested, due incompatible architecture.

Changes from V2:
 - added line break to debug message

Changes from V1:
 - Use %pR format type with the debug message (Thanks to Joe Perches)

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 422d9b5..645dac3 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1361,7 +1361,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
        __lpc_eth_clock_enable(pldat, true);
 
        /* Map IO space */
-       pldat->net_base = ioremap(res->start, res->end - res->start + 1);
+       pldat->net_base = ioremap(res->start, resource_size(res));
        if (!pldat->net_base) {
                dev_err(&pdev->dev, "failed to map registers\n");
                ret = -ENOMEM;
@@ -1417,10 +1417,8 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
        }
        pldat->dma_buff_base_p = dma_handle;
 
-       netdev_dbg(ndev, "IO address start     :0x%08x\n",
-                       res->start);
-       netdev_dbg(ndev, "IO address size      :%d\n",
-                       res->end - res->start + 1);
+       netdev_dbg(ndev, "IO address space     :%pR\n", res);
+       netdev_dbg(ndev, "IO address size      :%d\n", resource_size(res));
        netdev_dbg(ndev, "IO address (mapped)  :0x%p\n",
                        pldat->net_base);
        netdev_dbg(ndev, "IRQ number           :%d\n", ndev->irq);


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

* Re: [PATCH 2/2 v3] lpc_eth: Use resource_size instead of computation
  2014-06-02 11:34       ` [PATCH 2/2 v3] " Benoit Taine
@ 2014-06-02 17:58         ` David Miller
  2014-06-03 10:32         ` [PATCH 2/2 v4] " Benoit Taine
  1 sibling, 0 replies; 12+ messages in thread
From: David Miller @ 2014-06-02 17:58 UTC (permalink / raw)
  To: benoit.taine; +Cc: netdev, linux-kernel, kernel-janitors

From: Benoit Taine <benoit.taine@lip6.fr>
Date: Mon, 2 Jun 2014 13:34:30 +0200

> This issue was reported by coccicheck using the semantic patch 
> at scripts/coccinelle/api/resource_size.cocci
> 
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>

This patch doesn't apply cleanly to any of my trees.

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

* [PATCH 2/2 v4] lpc_eth: Use resource_size instead of computation
  2014-06-02 11:34       ` [PATCH 2/2 v3] " Benoit Taine
  2014-06-02 17:58         ` David Miller
@ 2014-06-03 10:32         ` Benoit Taine
  2014-06-03 10:45           ` [PATCH 2/2 v5] " Benoit Taine
  1 sibling, 1 reply; 12+ messages in thread
From: Benoit Taine @ 2014-06-03 10:32 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel, kernel-janitors

This issue was reported by coccicheck using the semantic patch 
at scripts/coccinelle/api/resource_size.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested, due incompatible architecture.

Changes from V3:
 - should now apply correctly

Changes from V2:
 - added line break to debug message

Changes from V1:
 - Use %pR format type with the debug message (Thanks to Joe Perches)

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 422d9b5..8706c0d 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1361,7 +1361,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
 	__lpc_eth_clock_enable(pldat, true);
 
 	/* Map IO space */
-	pldat->net_base = ioremap(res->start, res->end - res->start + 1);
+	pldat->net_base = ioremap(res->start, resource_size(res));
 	if (!pldat->net_base) {
 		dev_err(&pdev->dev, "failed to map registers\n");
 		ret = -ENOMEM;
@@ -1417,10 +1417,8 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
 	}
 	pldat->dma_buff_base_p = dma_handle;
 
-	netdev_dbg(ndev, "IO address start     :0x%08x\n",
-			res->start);
-	netdev_dbg(ndev, "IO address size      :%d\n",
-			res->end - res->start + 1);
+	netdev_dbg(ndev, "IO address space     :%pR\n", res);
+	netdev_dbg(ndev, "IO address size      :%d\n", resource_size(res));
 	netdev_dbg(ndev, "IO address (mapped)  :0x%p\n",
 			pldat->net_base);
 	netdev_dbg(ndev, "IRQ number           :%d\n", ndev->irq);

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

* [PATCH 2/2 v5] lpc_eth: Use resource_size instead of computation
  2014-06-03 10:32         ` [PATCH 2/2 v4] " Benoit Taine
@ 2014-06-03 10:45           ` Benoit Taine
  2014-06-03 23:09             ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Benoit Taine @ 2014-06-03 10:45 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel, kernel-janitors

This issue was reported by coccicheck using the semantic patch 
at scripts/coccinelle/api/resource_size.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested, due incompatible architecture.

Changes from V4:
 - Added blank line a the end of the diff (Thank to David Miller for your
   patience)

Changes from V3:
 - should now apply correctly

Changes from V2:
 - added line break to debug message

Changes from V1:
 - Use %pR format type with the debug message (Thanks to Joe Perches)

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 422d9b5..8706c0d 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1361,7 +1361,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
 	__lpc_eth_clock_enable(pldat, true);
 
 	/* Map IO space */
-	pldat->net_base = ioremap(res->start, res->end - res->start + 1);
+	pldat->net_base = ioremap(res->start, resource_size(res));
 	if (!pldat->net_base) {
 		dev_err(&pdev->dev, "failed to map registers\n");
 		ret = -ENOMEM;
@@ -1417,10 +1417,8 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
 	}
 	pldat->dma_buff_base_p = dma_handle;
 
-	netdev_dbg(ndev, "IO address start     :0x%08x\n",
-			res->start);
-	netdev_dbg(ndev, "IO address size      :%d\n",
-			res->end - res->start + 1);
+	netdev_dbg(ndev, "IO address space     :%pR\n", res);
+	netdev_dbg(ndev, "IO address size      :%d\n", resource_size(res));
 	netdev_dbg(ndev, "IO address (mapped)  :0x%p\n",
 			pldat->net_base);
 	netdev_dbg(ndev, "IRQ number           :%d\n", ndev->irq);


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

* Re: [PATCH 2/2 v5] lpc_eth: Use resource_size instead of computation
  2014-06-03 10:45           ` [PATCH 2/2 v5] " Benoit Taine
@ 2014-06-03 23:09             ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2014-06-03 23:09 UTC (permalink / raw)
  To: benoit.taine; +Cc: netdev, linux-kernel, kernel-janitors

From: Benoit Taine <benoit.taine@lip6.fr>
Date: Tue, 3 Jun 2014 12:45:59 +0200

> This issue was reported by coccicheck using the semantic patch 
> at scripts/coccinelle/api/resource_size.cocci
> 
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>

Applied, thanks.

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

end of thread, other threads:[~2014-06-03 23:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-28 15:14 [PATCH 0/2] Use resource_size instead of computation Benoit Taine
2014-05-28 15:14 ` [PATCH 1/2] ALSA: au1x00: " Benoit Taine
2014-05-28 15:51   ` Takashi Iwai
2014-05-28 15:14 ` [PATCH 2/2] lpc_eth: " Benoit Taine
2014-05-28 16:16   ` Joe Perches
2014-06-02  2:27   ` David Miller
2014-06-02 11:24     ` [PATCH 2/2 v2] " Benoit Taine
2014-06-02 11:34       ` [PATCH 2/2 v3] " Benoit Taine
2014-06-02 17:58         ` David Miller
2014-06-03 10:32         ` [PATCH 2/2 v4] " Benoit Taine
2014-06-03 10:45           ` [PATCH 2/2 v5] " Benoit Taine
2014-06-03 23:09             ` 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).