aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-09-23 18:57:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-24 10:21:04 -0400
commit30a61fff3a2b19506c66ea81fecb6a7747af3d47 (patch)
tree541f2337616caa095e517af0d4a0549a174818bd /drivers/edac
parentb4846251727a38a7f248e41308c060995371dd05 (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')
-rw-r--r--drivers/edac/cpc925_edac.c6
-rw-r--r--drivers/edac/mv64x60_edac.c22
2 files changed, 14 insertions, 14 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);
955err2: 955err2:
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));
957err1: 957err1:
958 devres_release_group(&pdev->dev, cpc925_probe); 958 devres_release_group(&pdev->dev, cpc925_probe);
959out: 959out:
diff --git a/drivers/edac/mv64x60_edac.c b/drivers/edac/mv64x60_edac.c
index 5131aaae8e03..a6b9fec13a74 100644
--- a/drivers/edac/mv64x60_edac.c
+++ b/drivers/edac/mv64x60_edac.c
@@ -90,7 +90,7 @@ static int __init mv64x60_pci_fixup(struct platform_device *pdev)
90 return -ENOENT; 90 return -ENOENT;
91 } 91 }
92 92
93 pci_serr = ioremap(r->start, r->end - r->start + 1); 93 pci_serr = ioremap(r->start, resource_size(r));
94 if (!pci_serr) 94 if (!pci_serr)
95 return -ENOMEM; 95 return -ENOMEM;
96 96
@@ -140,7 +140,7 @@ static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev)
140 140
141 if (!devm_request_mem_region(&pdev->dev, 141 if (!devm_request_mem_region(&pdev->dev,
142 r->start, 142 r->start,
143 r->end - r->start + 1, 143 resource_size(r),
144 pdata->name)) { 144 pdata->name)) {
145 printk(KERN_ERR "%s: Error while requesting mem region\n", 145 printk(KERN_ERR "%s: Error while requesting mem region\n",
146 __func__); 146 __func__);
@@ -150,7 +150,7 @@ static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev)
150 150
151 pdata->pci_vbase = devm_ioremap(&pdev->dev, 151 pdata->pci_vbase = devm_ioremap(&pdev->dev,
152 r->start, 152 r->start,
153 r->end - r->start + 1); 153 resource_size(r));
154 if (!pdata->pci_vbase) { 154 if (!pdata->pci_vbase) {
155 printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__); 155 printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__);
156 res = -ENOMEM; 156 res = -ENOMEM;
@@ -306,7 +306,7 @@ static int __devinit mv64x60_sram_err_probe(struct platform_device *pdev)
306 306
307 if (!devm_request_mem_region(&pdev->dev, 307 if (!devm_request_mem_region(&pdev->dev,
308 r->start, 308 r->start,
309 r->end - r->start + 1, 309 resource_size(r),
310 pdata->name)) { 310 pdata->name)) {
311 printk(KERN_ERR "%s: Error while request mem region\n", 311 printk(KERN_ERR "%s: Error while request mem region\n",
312 __func__); 312 __func__);
@@ -316,7 +316,7 @@ static int __devinit mv64x60_sram_err_probe(struct platform_device *pdev)
316 316
317 pdata->sram_vbase = devm_ioremap(&pdev->dev, 317 pdata->sram_vbase = devm_ioremap(&pdev->dev,
318 r->start, 318 r->start,
319 r->end - r->start + 1); 319 resource_size(r));
320 if (!pdata->sram_vbase) { 320 if (!pdata->sram_vbase) {
321 printk(KERN_ERR "%s: Unable to setup SRAM err regs\n", 321 printk(KERN_ERR "%s: Unable to setup SRAM err regs\n",
322 __func__); 322 __func__);
@@ -474,7 +474,7 @@ static int __devinit mv64x60_cpu_err_probe(struct platform_device *pdev)
474 474
475 if (!devm_request_mem_region(&pdev->dev, 475 if (!devm_request_mem_region(&pdev->dev,
476 r->start, 476 r->start,
477 r->end - r->start + 1, 477 resource_size(r),
478 pdata->name)) { 478 pdata->name)) {
479 printk(KERN_ERR "%s: Error while requesting mem region\n", 479 printk(KERN_ERR "%s: Error while requesting mem region\n",
480 __func__); 480 __func__);
@@ -484,7 +484,7 @@ static int __devinit mv64x60_cpu_err_probe(struct platform_device *pdev)
484 484
485 pdata->cpu_vbase[0] = devm_ioremap(&pdev->dev, 485 pdata->cpu_vbase[0] = devm_ioremap(&pdev->dev,
486 r->start, 486 r->start,
487 r->end - r->start + 1); 487 resource_size(r));
488 if (!pdata->cpu_vbase[0]) { 488 if (!pdata->cpu_vbase[0]) {
489 printk(KERN_ERR "%s: Unable to setup CPU err regs\n", __func__); 489 printk(KERN_ERR "%s: Unable to setup CPU err regs\n", __func__);
490 res = -ENOMEM; 490 res = -ENOMEM;
@@ -501,7 +501,7 @@ static int __devinit mv64x60_cpu_err_probe(struct platform_device *pdev)
501 501
502 if (!devm_request_mem_region(&pdev->dev, 502 if (!devm_request_mem_region(&pdev->dev,
503 r->start, 503 r->start,
504 r->end - r->start + 1, 504 resource_size(r),
505 pdata->name)) { 505 pdata->name)) {
506 printk(KERN_ERR "%s: Error while requesting mem region\n", 506 printk(KERN_ERR "%s: Error while requesting mem region\n",
507 __func__); 507 __func__);
@@ -511,7 +511,7 @@ static int __devinit mv64x60_cpu_err_probe(struct platform_device *pdev)
511 511
512 pdata->cpu_vbase[1] = devm_ioremap(&pdev->dev, 512 pdata->cpu_vbase[1] = devm_ioremap(&pdev->dev,
513 r->start, 513 r->start,
514 r->end - r->start + 1); 514 resource_size(r));
515 if (!pdata->cpu_vbase[1]) { 515 if (!pdata->cpu_vbase[1]) {
516 printk(KERN_ERR "%s: Unable to setup CPU err regs\n", __func__); 516 printk(KERN_ERR "%s: Unable to setup CPU err regs\n", __func__);
517 res = -ENOMEM; 517 res = -ENOMEM;
@@ -726,7 +726,7 @@ static int __devinit mv64x60_mc_err_probe(struct platform_device *pdev)
726 726
727 if (!devm_request_mem_region(&pdev->dev, 727 if (!devm_request_mem_region(&pdev->dev,
728 r->start, 728 r->start,
729 r->end - r->start + 1, 729 resource_size(r),
730 pdata->name)) { 730 pdata->name)) {
731 printk(KERN_ERR "%s: Error while requesting mem region\n", 731 printk(KERN_ERR "%s: Error while requesting mem region\n",
732 __func__); 732 __func__);
@@ -736,7 +736,7 @@ static int __devinit mv64x60_mc_err_probe(struct platform_device *pdev)
736 736
737 pdata->mc_vbase = devm_ioremap(&pdev->dev, 737 pdata->mc_vbase = devm_ioremap(&pdev->dev,
738 r->start, 738 r->start,
739 r->end - r->start + 1); 739 resource_size(r));
740 if (!pdata->mc_vbase) { 740 if (!pdata->mc_vbase) {
741 printk(KERN_ERR "%s: Unable to setup MC err regs\n", __func__); 741 printk(KERN_ERR "%s: Unable to setup MC err regs\n", __func__);
742 res = -ENOMEM; 742 res = -ENOMEM;