Commit d60f6c2b authored by Ben Dooks's avatar Ben Dooks Committed by Linus Torvalds

sm501: fix missing uses of resource_size()

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
Signed-off-by: default avatarBen Dooks <ben@simtec.co.uk>
Signed-off-by: default avatarSimtec Linux Team <linux@simtec.co.uk>
Cc: Vincent Sanders <vince@simtec.co.uk>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b689a9e8
...@@ -1338,7 +1338,7 @@ static int sm501fb_start(struct sm501fb_info *info, ...@@ -1338,7 +1338,7 @@ static int sm501fb_start(struct sm501fb_info *info,
} }
info->regs_res = request_mem_region(res->start, info->regs_res = request_mem_region(res->start,
res->end - res->start, resource_size(res),
pdev->name); pdev->name);
if (info->regs_res == NULL) { if (info->regs_res == NULL) {
...@@ -1347,7 +1347,7 @@ static int sm501fb_start(struct sm501fb_info *info, ...@@ -1347,7 +1347,7 @@ static int sm501fb_start(struct sm501fb_info *info,
goto err_release; 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) { if (info->regs == NULL) {
dev_err(dev, "cannot remap registers\n"); dev_err(dev, "cannot remap registers\n");
ret = -ENXIO; ret = -ENXIO;
...@@ -1363,7 +1363,7 @@ static int sm501fb_start(struct sm501fb_info *info, ...@@ -1363,7 +1363,7 @@ static int sm501fb_start(struct sm501fb_info *info,
} }
info->fbmem_res = request_mem_region(res->start, info->fbmem_res = request_mem_region(res->start,
(res->end - res->start)+1, resource_size(res),
pdev->name); pdev->name);
if (info->fbmem_res == NULL) { if (info->fbmem_res == NULL) {
dev_err(dev, "cannot claim framebuffer\n"); dev_err(dev, "cannot claim framebuffer\n");
...@@ -1371,13 +1371,13 @@ static int sm501fb_start(struct sm501fb_info *info, ...@@ -1371,13 +1371,13 @@ static int sm501fb_start(struct sm501fb_info *info,
goto err_regs_map; goto err_regs_map;
} }
info->fbmem = ioremap(res->start, (res->end - res->start)+1); info->fbmem = ioremap(res->start, resource_size(res));
if (info->fbmem == NULL) { if (info->fbmem == NULL) {
dev_err(dev, "cannot remap framebuffer\n"); dev_err(dev, "cannot remap framebuffer\n");
goto err_mem_res; 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 */ /* clear framebuffer memory - avoids garbage data on unused fb */
memset(info->fbmem, 0, info->fbmem_len); memset(info->fbmem, 0, info->fbmem_len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment