]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
i2c: Use resource_size
authorJulia Lawall <julia@diku.dk>
Sun, 5 Jul 2009 06:37:50 +0000 (08:37 +0200)
committerBen Dooks <ben-linux@fluff.org>
Tue, 14 Jul 2009 23:03:56 +0000 (00:03 +0100)
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>
drivers/i2c/busses/i2c-davinci.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/i2c/busses/i2c-simtec.c

index 1f3d89c3194a48c82971a46c5ecc667eec2298ff..c89687a10835538307212949317042f40042129c 100644 (file)
@@ -515,7 +515,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1,
+       ioarea = request_mem_region(mem->start, resource_size(mem),
                                    pdev->name);
        if (!ioarea) {
                dev_err(&pdev->dev, "I2C region already claimed\n");
@@ -578,7 +578,7 @@ err_free_mem:
        put_device(&pdev->dev);
        kfree(dev);
 err_release_region:
-       release_mem_region(mem->start, (mem->end - mem->start) + 1);
+       release_mem_region(mem->start, resource_size(mem));
 
        return r;
 }
@@ -601,7 +601,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
        kfree(dev);
 
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(mem->start, (mem->end - mem->start) + 1);
+       release_mem_region(mem->start, resource_size(mem));
        return 0;
 }
 
index ad8d2010c9211cf0f28f9201aa7346662357626b..fdd83277c8a81ac22441ce7ddea5188b0247e34f 100644 (file)
@@ -806,7 +806,7 @@ omap_i2c_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1,
+       ioarea = request_mem_region(mem->start, resource_size(mem),
                        pdev->name);
        if (!ioarea) {
                dev_err(&pdev->dev, "I2C region already claimed\n");
@@ -905,7 +905,7 @@ err_free_mem:
        platform_set_drvdata(pdev, NULL);
        kfree(dev);
 err_release_region:
-       release_mem_region(mem->start, (mem->end - mem->start) + 1);
+       release_mem_region(mem->start, resource_size(mem));
 
        return r;
 }
@@ -925,7 +925,7 @@ omap_i2c_remove(struct platform_device *pdev)
        iounmap(dev->base);
        kfree(dev);
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(mem->start, (mem->end - mem->start) + 1);
+       release_mem_region(mem->start, resource_size(mem));
        return 0;
 }
 
index 1c01083b01b5ac0bc3f7eac54a657a72fb049ea0..4f3d99cd16927c2d9ae57c6bbda6d3894e5a9f6b 100644 (file)
@@ -563,7 +563,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
                goto err_irq;
        }
 
-       size = (res->end - res->start) + 1;
+       size = resource_size(res);
 
        pd->reg = ioremap(res->start, size);
        if (pd->reg == NULL) {
index 042fda295f3a557cd56c623a6aab980ae362271e..6407f47bda82db92b5ba2f2926851f774a938e91 100644 (file)
@@ -92,7 +92,7 @@ static int simtec_i2c_probe(struct platform_device *dev)
                goto err;
        }
 
-       size = (res->end-res->start)+1;
+       size = resource_size(res);
 
        pd->ioarea = request_mem_region(res->start, size, dev->name);
        if (pd->ioarea == NULL) {