Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 041b5eac authored by Julia Lawall's avatar Julia Lawall Committed by Jeff Garzik
Browse files

drivers/ata: 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: default avatarJulia Lawall <julia@diku.dk>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent f90f613c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -841,7 +841,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
	ocd = pdev->dev.platform_data;
	ocd = pdev->dev.platform_data;


	cs0 = devm_ioremap_nocache(&pdev->dev, res_cs0->start,
	cs0 = devm_ioremap_nocache(&pdev->dev, res_cs0->start,
				   res_cs0->end - res_cs0->start + 1);
				   resource_size(res_cs0));


	if (!cs0)
	if (!cs0)
		return -ENOMEM;
		return -ENOMEM;
+4 −4
Original line number Original line Diff line number Diff line
@@ -151,14 +151,14 @@ int __devinit __pata_platform_probe(struct device *dev,
	 */
	 */
	if (mmio) {
	if (mmio) {
		ap->ioaddr.cmd_addr = devm_ioremap(dev, io_res->start,
		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,
		ap->ioaddr.ctl_addr = devm_ioremap(dev, ctl_res->start,
				ctl_res->end - ctl_res->start + 1);
				resource_size(ctl_res));
	} else {
	} else {
		ap->ioaddr.cmd_addr = devm_ioport_map(dev, io_res->start,
		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,
		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) {
	if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) {
		dev_err(dev, "failed to map IO/CTL base\n");
		dev_err(dev, "failed to map IO/CTL base\n");
+1 −1
Original line number Original line Diff line number Diff line
@@ -151,7 +151,7 @@ static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
	info->irq = irq;
	info->irq = irq;


	info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
	info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
				res->end - res->start + 1);
				resource_size(res));
	if (!info->iobase)
	if (!info->iobase)
		return -ENOMEM;
		return -ENOMEM;


+1 −1
Original line number Original line Diff line number Diff line
@@ -4013,7 +4013,7 @@ static int mv_platform_probe(struct platform_device *pdev)


	host->iomap = NULL;
	host->iomap = NULL;
	hpriv->base = devm_ioremap(&pdev->dev, res->start,
	hpriv->base = devm_ioremap(&pdev->dev, res->start,
				   res->end - res->start + 1);
				   resource_size(res));
	hpriv->base -= SATAHC0_REG_BASE;
	hpriv->base -= SATAHC0_REG_BASE;


	/*
	/*