Skip to contentSkip to conversation

ALSA: au1x00: Use resource_size

PATCH In review Himangi Saraogi 2 participants 2 messages Jun 12, 2014 – Jun 13, 2014 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: au1x00: Use resource_size

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>

---
Not compile tested.

 sound/mips/au1x00.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/mips/au1x00.c +1 -1
index d10ef76..86583c7 100644
@@ -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;
Signature · 1 line
1.9.1
#1 lore raw

At Fri, 13 Jun 2014 03:32:07 +0530,

Quoted 11 lines · Himangi Saraogi

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;
@@

Quoted 6 lines

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

This was already fixed in sound git tree.

thanks,

Takashi

Quoted 21 lines

---
Not compile tested.

 sound/mips/au1x00.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/mips/au1x00.c +1 -1
index d10ef76..86583c7 100644
@@ -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;
Signature · 1 line
1.9.1