Skip to contentSkip to conversation

SM501: Fix missing uses of resource_size()

PATCH Ben Dooks 3 participants 5 messages Nov 10, 2009 Framebuffer layer

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

There are several places in the SM501 fb driver that could do with using resource_size() to calculate the size of a resource.

Also fix a bug where request_mem_region() is being passed one too few bytes when requesting the register memory region, which was causing the following in /proc/iomem:

13e80000-13e8ffff : sm501-fb.0
13e80000-13e8fffe : sm501-fb

fixed, this reads:

13e80000-13e8ffff : sm501-fb.0
13e80000-13e8ffff : sm501-fb

---
 drivers/video/sm501fb.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/sm501fb.c +4 -4
Index: b/drivers/video/sm501fb.c
===================================================================
@@ -1338,7 +1338,7 @@ static int sm501fb_start(struct sm501fb_
 	}
 
 	info->regs_res = request_mem_region(res->start,
-					    res->end - res->start,
+					    resource_size(res),
 					    pdev->name);
 
 	if (info->regs_res == NULL) {
@@ -1347,7 +1347,7 @@ static int sm501fb_start(struct sm501fb_
 		goto err_release;
 	}
 
-	info->regs = ioremap(res->start, (res->end - res->start)+1);
+	info->regs = ioremap(res->start, resource_size(res));
 	if (info->regs == NULL) {
 		dev_err(dev, "cannot remap registers\n");
 		ret = -ENXIO;
@@ -1363,7 +1363,7 @@ static int sm501fb_start(struct sm501fb_
 	}
 
 	info->fbmem_res = request_mem_region(res->start,
-					     (res->end - res->start)+1,
+					     resource_size(res),
 					     pdev->name);
 	if (info->fbmem_res == NULL) {
 		dev_err(dev, "cannot claim framebuffer\n");
@@ -1377,7 +1377,7 @@ static int sm501fb_start(struct sm501fb_
 		goto err_mem_res;
 	}
 
-	info->fbmem_len = (res->end - res->start)+1;
+	info->fbmem_len = resource_size(res);
 
 	/* clear framebuffer memory - avoids garbage data on unused fb */
 	memset(info->fbmem, 0, info->fbmem_len);
Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
#1 lore raw

Could you attach the patch as a plain text in the body of email and [PATCH] at the subject line?

#3 lore raw
In reply to Ben Dooks
Quoted 3 lines · On Tue, 10 Nov 2009 17:17:34 +0000 Ben Dooks <[email protected]> wrote:

There are several places in the SM501 fb driver that could do with using resource_size() to calculate the size of a resource.

Yes, please! Also, as Thiago suggested, please submit this inline.

[...]

drivers/video/sm501fb.c static int sm501fb_start(struct sm501fb_

Quoted 11 lines
drivers/video/sm501fb.c +1 -1
@@ -1363,7 +1363,7 @@ static int sm501fb_start(struct sm501fb_
 	}
 
 	info->fbmem_res = request_mem_region(res->start,
-					     (res->end -
 res->start)+1,
+					     resource_size(res),
 					     pdev->name);
 	if (info->fbmem_res == NULL) {
drivers/video/sm501fb.c +0 -0
 		dev_err(dev, "cannot claim framebuffer\n");
@@ -1377,7 +1377,7 @@ static int sm501fb_start(struct sm501fb_

Looks like you missed one here; the ioremap on line 1374 should also use resource_size.

Quoted 9 lines
drivers/video/sm501fb.c +1 -1
 		goto err_mem_res;
 	}
 
-	info->fbmem_len = (res->end - res->start)+1;
+	info->fbmem_len = resource_size(res);
 
 	/* clear framebuffer memory - avoids garbage data on unused
 fb */ memset(info->fbmem, 0, info->fbmem_len);
author
#2 lore raw
In reply to Thiago Farina
Quoted 1 line · Thiago Farina

Could you attach the patch as a plain text in the body of email and

quilt mail seems to work fine in my mailer.

[trimmed the cc: line]

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
author
#4 lore raw
In reply to Andres Salomon
Quoted 8 lines · Andres Salomon
Quoted 3 lines · On Tue, 10 Nov 2009 17:17:34 +0000 Ben Dooks <[email protected]> wrote:

There are several places in the SM501 fb driver that could do with using resource_size() to calculate the size of a resource.

Yes, please! Also, as Thiago suggested, please submit this inline.

My mailer shows it in line. using quilt mail to send, and it says that the content has been inlined.

Quoted 4 lines

[...]

Quoted 3 lines
(quoted diff) +0 -0
@@ -1363,7 +1363,7 @@ static int sm501fb_start(struct sm501fb_
 	}
 
Quoted 11 lines

drivers/video/sm501fb.c static int sm501fb_start(struct sm501fb_

Quoted 8 lines
drivers/video/sm501fb.c +1 -1
 	info->fbmem_res = request_mem_region(res->start,
-					     (res->end -
 res->start)+1,
+					     resource_size(res),
 					     pdev->name);
 	if (info->fbmem_res == NULL) {
drivers/video/sm501fb.c +0 -0
 		dev_err(dev, "cannot claim framebuffer\n");
@@ -1377,7 +1377,7 @@ static int sm501fb_start(struct sm501fb_

Looks like you missed one here; the ioremap on line 1374 should also use resource_size.

thanks, fixed.

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'