diff options
author | Julia Lawall <julia@diku.dk> | 2009-09-23 18:57:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-24 10:21:04 -0400 |
commit | 30a61fff3a2b19506c66ea81fecb6a7747af3d47 (patch) | |
tree | 541f2337616caa095e517af0d4a0549a174818bd /drivers/edac/cpc925_edac.c | |
parent | b4846251727a38a7f248e41308c060995371dd05 (diff) |
edac: fix resource size calculation
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:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
struct resource *res;
@@
- (res->end - res->start) + 1
+ resource_size(res)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Doug Thompson <dougthompson@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/edac/cpc925_edac.c')
-rw-r--r-- | drivers/edac/cpc925_edac.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c index 8c54196b5aba..3d50274f1348 100644 --- a/drivers/edac/cpc925_edac.c +++ b/drivers/edac/cpc925_edac.c | |||
@@ -885,14 +885,14 @@ static int __devinit cpc925_probe(struct platform_device *pdev) | |||
885 | 885 | ||
886 | if (!devm_request_mem_region(&pdev->dev, | 886 | if (!devm_request_mem_region(&pdev->dev, |
887 | r->start, | 887 | r->start, |
888 | r->end - r->start + 1, | 888 | resource_size(r), |
889 | pdev->name)) { | 889 | pdev->name)) { |
890 | cpc925_printk(KERN_ERR, "Unable to request mem region\n"); | 890 | cpc925_printk(KERN_ERR, "Unable to request mem region\n"); |
891 | res = -EBUSY; | 891 | res = -EBUSY; |
892 | goto err1; | 892 | goto err1; |
893 | } | 893 | } |
894 | 894 | ||
895 | vbase = devm_ioremap(&pdev->dev, r->start, r->end - r->start + 1); | 895 | vbase = devm_ioremap(&pdev->dev, r->start, resource_size(r)); |
896 | if (!vbase) { | 896 | if (!vbase) { |
897 | cpc925_printk(KERN_ERR, "Unable to ioremap device\n"); | 897 | cpc925_printk(KERN_ERR, "Unable to ioremap device\n"); |
898 | res = -ENOMEM; | 898 | res = -ENOMEM; |
@@ -953,7 +953,7 @@ err3: | |||
953 | cpc925_mc_exit(mci); | 953 | cpc925_mc_exit(mci); |
954 | edac_mc_free(mci); | 954 | edac_mc_free(mci); |
955 | err2: | 955 | err2: |
956 | devm_release_mem_region(&pdev->dev, r->start, r->end-r->start+1); | 956 | devm_release_mem_region(&pdev->dev, r->start, resource_size(r)); |
957 | err1: | 957 | err1: |
958 | devres_release_group(&pdev->dev, cpc925_probe); | 958 | devres_release_group(&pdev->dev, cpc925_probe); |
959 | out: | 959 | out: |