]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
drivers/ata: use resource_size
authorJulia Lawall <julia@diku.dk>
Thu, 6 Aug 2009 23:05:08 +0000 (16:05 -0700)
committerJeff Garzik <jgarzik@redhat.com>
Fri, 11 Sep 2009 06:25:58 +0000 (02:25 -0400)
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>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/ata/pata_octeon_cf.c
drivers/ata/pata_platform.c
drivers/ata/pata_rb532_cf.c
drivers/ata/sata_mv.c

index e807cc3b6ab4e20d7e2061e074456bde6eba6dc4..d6f69561dc86f78bea2d3d6fc017c95a74281805 100644 (file)
@@ -841,7 +841,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
        ocd = pdev->dev.platform_data;
 
        cs0 = devm_ioremap_nocache(&pdev->dev, res_cs0->start,
-                                  res_cs0->end - res_cs0->start + 1);
+                                  resource_size(res_cs0));
 
        if (!cs0)
                return -ENOMEM;
index d8d743af32250fe60cbf766ff77eb6a0079bde50..3f6ebc6c665a4f2f6189ec1852b642fb31e040a2 100644 (file)
@@ -151,14 +151,14 @@ int __devinit __pata_platform_probe(struct device *dev,
         */
        if (mmio) {
                ap->ioaddr.cmd_addr = devm_ioremap(dev, io_res->start,
-                               io_res->end - io_res->start + 1);
+                               resource_size(io_res));
                ap->ioaddr.ctl_addr = devm_ioremap(dev, ctl_res->start,
-                               ctl_res->end - ctl_res->start + 1);
+                               resource_size(ctl_res));
        } else {
                ap->ioaddr.cmd_addr = devm_ioport_map(dev, io_res->start,
-                               io_res->end - io_res->start + 1);
+                               resource_size(io_res));
                ap->ioaddr.ctl_addr = devm_ioport_map(dev, ctl_res->start,
-                               ctl_res->end - ctl_res->start + 1);
+                               resource_size(ctl_res));
        }
        if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) {
                dev_err(dev, "failed to map IO/CTL base\n");
index 8e3cdef8a25fb2a750e34a311bb41778881a87fd..45f1e10f917b473f41f19cf1859658d2f3bb95c7 100644 (file)
@@ -151,7 +151,7 @@ static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
        info->irq = irq;
 
        info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
-                               res->end - res->start + 1);
+                               resource_size(res));
        if (!info->iobase)
                return -ENOMEM;
 
index c19417e02208f3c500c269fcdf5b8846ff19464b..17f9ff9067a2b3dd6e185719e4086b3aa196a17f 100644 (file)
@@ -4013,7 +4013,7 @@ static int mv_platform_probe(struct platform_device *pdev)
 
        host->iomap = NULL;
        hpriv->base = devm_ioremap(&pdev->dev, res->start,
-                                  res->end - res->start + 1);
+                                  resource_size(res));
        hpriv->base -= SATAHC0_REG_BASE;
 
        /*