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/busses/i2c-davinci.c | |
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/busses/i2c-davinci.c')
-rw-r--r-- | drivers/i2c/busses/i2c-davinci.c | 6 |
1 files changed, 3 insertions, 3 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 | ||