[ARM] 5544/1: Trust PrimeCell resource sizes

I found the PrimeCell/AMBA Bus drivers distrusting the resource
passed in as part of the struct amba_device abstraction. This
patch removes all hard coded resource sizes found in the PrimeCell
drivers and move the responsibility of this definition back to
the platform/board device definition, which already exist and
appear to be correct for all in-tree users of these drivers.
We do this using the resource_size() inline function which was
also replicated in the only driver using the resource size, so
that has been changed too. The KMI_SIZE was left in kmi.h in case
someone likes it. Test-compiled against Versatile and Integrator
defconfigs, seems to work but I don't posess these boards and
cannot test them.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
This commit is contained in:
Linus Walleij 2009-06-07 23:27:31 +01:00 committed by Russell King
parent 42578c82e0
commit dc890c2dcd
8 changed files with 8 additions and 9 deletions

View file

@ -135,7 +135,7 @@ static int amba_kmi_probe(struct amba_device *dev, struct amba_id *id)
io->dev.parent = &dev->dev; io->dev.parent = &dev->dev;
kmi->io = io; kmi->io = io;
kmi->base = ioremap(dev->res.start, KMI_SIZE); kmi->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!kmi->base) { if (!kmi->base) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;

View file

@ -546,7 +546,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
host->mclk = clk_get_rate(host->clk); host->mclk = clk_get_rate(host->clk);
DBG(host, "eventual mclk rate: %u Hz\n", host->mclk); DBG(host, "eventual mclk rate: %u Hz\n", host->mclk);
} }
host->base = ioremap(dev->res.start, SZ_4K); host->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!host->base) { if (!host->base) {
ret = -ENOMEM; ret = -ENOMEM;
goto clk_disable; goto clk_disable;

View file

@ -117,7 +117,7 @@ static int pl030_probe(struct amba_device *dev, struct amba_id *id)
goto err_rtc; goto err_rtc;
} }
rtc->base = ioremap(dev->res.start, SZ_4K); rtc->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!rtc->base) { if (!rtc->base) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_map; goto err_map;

View file

@ -142,8 +142,7 @@ static int pl031_probe(struct amba_device *adev, struct amba_id *id)
goto out; goto out;
} }
ldata->base = ioremap(adev->res.start, ldata->base = ioremap(adev->res.start, resource_size(&adev->res));
adev->res.end - adev->res.start + 1);
if (!ldata->base) { if (!ldata->base) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_no_remap; goto out_no_remap;

View file

@ -686,7 +686,7 @@ static int pl010_probe(struct amba_device *dev, struct amba_id *id)
goto out; goto out;
} }
base = ioremap(dev->res.start, PAGE_SIZE); base = ioremap(dev->res.start, resource_size(&dev->res));
if (!base) { if (!base) {
ret = -ENOMEM; ret = -ENOMEM;
goto free; goto free;

View file

@ -767,7 +767,7 @@ static int pl011_probe(struct amba_device *dev, struct amba_id *id)
goto out; goto out;
} }
base = ioremap(dev->res.start, PAGE_SIZE); base = ioremap(dev->res.start, resource_size(&dev->res));
if (!base) { if (!base) {
ret = -ENOMEM; ret = -ENOMEM;
goto free; goto free;

View file

@ -351,7 +351,7 @@ static int clcdfb_register(struct clcd_fb *fb)
} }
fb->fb.fix.mmio_start = fb->dev->res.start; fb->fb.fix.mmio_start = fb->dev->res.start;
fb->fb.fix.mmio_len = 4096; fb->fb.fix.mmio_len = resource_size(&fb->dev->res);
fb->regs = ioremap(fb->fb.fix.mmio_start, fb->fb.fix.mmio_len); fb->regs = ioremap(fb->fb.fix.mmio_start, fb->fb.fix.mmio_len);
if (!fb->regs) { if (!fb->regs) {

View file

@ -1089,7 +1089,7 @@ static int __devinit aaci_probe(struct amba_device *dev, struct amba_id *id)
goto out; goto out;
} }
aaci->base = ioremap(dev->res.start, SZ_4K); aaci->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!aaci->base) { if (!aaci->base) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;