diff options
author | Julia Lawall <julia@diku.dk> | 2009-07-05 02:37:50 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2009-07-14 19:03:56 -0400 |
commit | 593308259bbd335eda9c5280cdd1f7883c746211 (patch) | |
tree | 60c9882dec12dfa7a262f1d14a81b8318d45d0f4 /drivers/i2c | |
parent | 7605fa3b0aedbb6c77471517ba16753f276156d9 (diff) |
i2c: 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:
(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: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-davinci.c | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-simtec.c | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 1f3d89c3194a..c89687a10835 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c | |||
@@ -515,7 +515,7 @@ static int davinci_i2c_probe(struct platform_device *pdev) | |||
515 | return -ENODEV; | 515 | return -ENODEV; |
516 | } | 516 | } |
517 | 517 | ||
518 | ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1, | 518 | ioarea = request_mem_region(mem->start, resource_size(mem), |
519 | pdev->name); | 519 | pdev->name); |
520 | if (!ioarea) { | 520 | if (!ioarea) { |
521 | dev_err(&pdev->dev, "I2C region already claimed\n"); | 521 | dev_err(&pdev->dev, "I2C region already claimed\n"); |
@@ -578,7 +578,7 @@ err_free_mem: | |||
578 | put_device(&pdev->dev); | 578 | put_device(&pdev->dev); |
579 | kfree(dev); | 579 | kfree(dev); |
580 | err_release_region: | 580 | err_release_region: |
581 | release_mem_region(mem->start, (mem->end - mem->start) + 1); | 581 | release_mem_region(mem->start, resource_size(mem)); |
582 | 582 | ||
583 | return r; | 583 | return r; |
584 | } | 584 | } |
@@ -601,7 +601,7 @@ static int davinci_i2c_remove(struct platform_device *pdev) | |||
601 | kfree(dev); | 601 | kfree(dev); |
602 | 602 | ||
603 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 603 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
604 | release_mem_region(mem->start, (mem->end - mem->start) + 1); | 604 | release_mem_region(mem->start, resource_size(mem)); |
605 | return 0; | 605 | return 0; |
606 | } | 606 | } |
607 | 607 | ||
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index ad8d2010c921..fdd83277c8a8 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -806,7 +806,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
806 | return -ENODEV; | 806 | return -ENODEV; |
807 | } | 807 | } |
808 | 808 | ||
809 | ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1, | 809 | ioarea = request_mem_region(mem->start, resource_size(mem), |
810 | pdev->name); | 810 | pdev->name); |
811 | if (!ioarea) { | 811 | if (!ioarea) { |
812 | dev_err(&pdev->dev, "I2C region already claimed\n"); | 812 | dev_err(&pdev->dev, "I2C region already claimed\n"); |
@@ -905,7 +905,7 @@ err_free_mem: | |||
905 | platform_set_drvdata(pdev, NULL); | 905 | platform_set_drvdata(pdev, NULL); |
906 | kfree(dev); | 906 | kfree(dev); |
907 | err_release_region: | 907 | err_release_region: |
908 | release_mem_region(mem->start, (mem->end - mem->start) + 1); | 908 | release_mem_region(mem->start, resource_size(mem)); |
909 | 909 | ||
910 | return r; | 910 | return r; |
911 | } | 911 | } |
@@ -925,7 +925,7 @@ omap_i2c_remove(struct platform_device *pdev) | |||
925 | iounmap(dev->base); | 925 | iounmap(dev->base); |
926 | kfree(dev); | 926 | kfree(dev); |
927 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 927 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
928 | release_mem_region(mem->start, (mem->end - mem->start) + 1); | 928 | release_mem_region(mem->start, resource_size(mem)); |
929 | return 0; | 929 | return 0; |
930 | } | 930 | } |
931 | 931 | ||
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 1c01083b01b5..4f3d99cd1692 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -563,7 +563,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
563 | goto err_irq; | 563 | goto err_irq; |
564 | } | 564 | } |
565 | 565 | ||
566 | size = (res->end - res->start) + 1; | 566 | size = resource_size(res); |
567 | 567 | ||
568 | pd->reg = ioremap(res->start, size); | 568 | pd->reg = ioremap(res->start, size); |
569 | if (pd->reg == NULL) { | 569 | if (pd->reg == NULL) { |
diff --git a/drivers/i2c/busses/i2c-simtec.c b/drivers/i2c/busses/i2c-simtec.c index 042fda295f3a..6407f47bda82 100644 --- a/drivers/i2c/busses/i2c-simtec.c +++ b/drivers/i2c/busses/i2c-simtec.c | |||
@@ -92,7 +92,7 @@ static int simtec_i2c_probe(struct platform_device *dev) | |||
92 | goto err; | 92 | goto err; |
93 | } | 93 | } |
94 | 94 | ||
95 | size = (res->end-res->start)+1; | 95 | size = resource_size(res); |
96 | 96 | ||
97 | pd->ioarea = request_mem_region(res->start, size, dev->name); | 97 | pd->ioarea = request_mem_region(res->start, size, dev->name); |
98 | if (pd->ioarea == NULL) { | 98 | if (pd->ioarea == NULL) { |