All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: au1x00: Use resource_size
@ 2014-06-12 22:02 Himangi Saraogi
  2014-06-13  8:48 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-06-12 22:02 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel; +Cc: julia.lawall

Use the function resource_size, which reduces the chance of introducing
off-by-one errors in calculating the resource size.

The semantic patch that makes this change is as follows:

// <smpl>
@@
struct resource *res;
@@

- (res->end - res->start) + 1
+ resource_size(res)
// </smpl>

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
Not compile tested.
 sound/mips/au1x00.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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


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

* Re: [PATCH] ALSA: au1x00: Use resource_size
  2014-06-12 22:02 [PATCH] ALSA: au1x00: Use resource_size Himangi Saraogi
@ 2014-06-13  8:48 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2014-06-13  8:48 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: Jaroslav Kysela, alsa-devel, linux-kernel, julia.lawall

At Fri, 13 Jun 2014 03:32:07 +0530,
Himangi Saraogi wrote:
> 
> Use the function resource_size, which reduces the chance of introducing
> off-by-one errors in calculating the resource size.
> 
> The semantic patch that makes this change is as follows:
> 
> // <smpl>
> @@
> struct resource *res;
> @@
> 
> - (res->end - res->start) + 1
> + resource_size(res)
> // </smpl>
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

This was already fixed in sound git tree.


thanks,

Takashi

> ---
> Not compile tested.
>  sound/mips/au1x00.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
> index d10ef76..86583c7 100644
> --- a/sound/mips/au1x00.c
> +++ b/sound/mips/au1x00.c
> @@ -649,7 +649,7 @@ static int au1000_ac97_probe(struct platform_device *pdev)
>  
>  	err = -EBUSY;
>  	au1000->ac97_res_port = request_mem_region(r->start,
> -					r->end - r->start + 1, pdev->name);
> +					resource_size(r), pdev->name);
>  	if (!au1000->ac97_res_port) {
>  		snd_printk(KERN_ERR "ALSA AC97: can't grab AC97 port\n");
>  		goto out;
> -- 
> 1.9.1
> 

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

end of thread, other threads:[~2014-06-13  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 22:02 [PATCH] ALSA: au1x00: Use resource_size Himangi Saraogi
2014-06-13  8:48 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.