Commit 5ef650ae authored by Wan ZongShun's avatar Wan ZongShun Committed by Mark Brown

ASoC: s6000: use resource_size for {request/release}_mem_region and ioremap

The size calculation is end - start + 1. But,sometimes, the '1' can
be forgotten carelessly, witch will have potential risk, so use resource_size
for {request/release}_mem_region and ioremap here should be good habit.
Signed-off-by: default avatarWan ZongShun <mcuos.com@gmail.com>
Acked-by: default avatarDaniel Glöckner <dg@emlix.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 85252b6a
...@@ -451,16 +451,15 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev) ...@@ -451,16 +451,15 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev)
goto err_release_none; goto err_release_none;
} }
region = request_mem_region(scbmem->start, region = request_mem_region(scbmem->start, resource_size(scbmem),
scbmem->end - scbmem->start + 1, pdev->name);
pdev->name);
if (!region) { if (!region) {
dev_err(&pdev->dev, "I2S SCB region already claimed\n"); dev_err(&pdev->dev, "I2S SCB region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
goto err_release_none; goto err_release_none;
} }
mmio = ioremap(scbmem->start, scbmem->end - scbmem->start + 1); mmio = ioremap(scbmem->start, resource_size(scbmem));
if (!mmio) { if (!mmio) {
dev_err(&pdev->dev, "can't ioremap SCB region\n"); dev_err(&pdev->dev, "can't ioremap SCB region\n");
ret = -ENOMEM; ret = -ENOMEM;
...@@ -474,9 +473,8 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev) ...@@ -474,9 +473,8 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev)
goto err_release_map; goto err_release_map;
} }
region = request_mem_region(sifmem->start, region = request_mem_region(sifmem->start, resource_size(sifmem),
sifmem->end - sifmem->start + 1, pdev->name);
pdev->name);
if (!region) { if (!region) {
dev_err(&pdev->dev, "I2S SIF region already claimed\n"); dev_err(&pdev->dev, "I2S SIF region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
...@@ -490,8 +488,8 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev) ...@@ -490,8 +488,8 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev)
goto err_release_sif; goto err_release_sif;
} }
region = request_mem_region(dma1->start, dma1->end - dma1->start + 1, region = request_mem_region(dma1->start, resource_size(dma1),
pdev->name); pdev->name);
if (!region) { if (!region) {
dev_err(&pdev->dev, "I2S DMA region already claimed\n"); dev_err(&pdev->dev, "I2S DMA region already claimed\n");
ret = -EBUSY; ret = -EBUSY;
...@@ -500,9 +498,8 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev) ...@@ -500,9 +498,8 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev)
dma2 = platform_get_resource(pdev, IORESOURCE_DMA, 1); dma2 = platform_get_resource(pdev, IORESOURCE_DMA, 1);
if (dma2) { if (dma2) {
region = request_mem_region(dma2->start, region = request_mem_region(dma2->start, resource_size(dma2),
dma2->end - dma2->start + 1, pdev->name);
pdev->name);
if (!region) { if (!region) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"I2S DMA region already claimed\n"); "I2S DMA region already claimed\n");
...@@ -561,15 +558,15 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev) ...@@ -561,15 +558,15 @@ static int __devinit s6000_i2s_probe(struct platform_device *pdev)
kfree(dev); kfree(dev);
err_release_dma2: err_release_dma2:
if (dma2) if (dma2)
release_mem_region(dma2->start, dma2->end - dma2->start + 1); release_mem_region(dma2->start, resource_size(dma2));
err_release_dma1: err_release_dma1:
release_mem_region(dma1->start, dma1->end - dma1->start + 1); release_mem_region(dma1->start, resource_size(dma1));
err_release_sif: err_release_sif:
release_mem_region(sifmem->start, (sifmem->end - sifmem->start) + 1); release_mem_region(sifmem->start, resource_size(sifmem));
err_release_map: err_release_map:
iounmap(mmio); iounmap(mmio);
err_release_scb: err_release_scb:
release_mem_region(scbmem->start, (scbmem->end - scbmem->start) + 1); release_mem_region(scbmem->start, resource_size(scbmem));
err_release_none: err_release_none:
return ret; return ret;
} }
...@@ -590,19 +587,18 @@ static void __devexit s6000_i2s_remove(struct platform_device *pdev) ...@@ -590,19 +587,18 @@ static void __devexit s6000_i2s_remove(struct platform_device *pdev)
kfree(dev); kfree(dev);
region = platform_get_resource(pdev, IORESOURCE_DMA, 0); region = platform_get_resource(pdev, IORESOURCE_DMA, 0);
release_mem_region(region->start, region->end - region->start + 1); release_mem_region(region->start, resource_size(region));
region = platform_get_resource(pdev, IORESOURCE_DMA, 1); region = platform_get_resource(pdev, IORESOURCE_DMA, 1);
if (region) if (region)
release_mem_region(region->start, release_mem_region(region->start, resource_size(region));
region->end - region->start + 1);
region = platform_get_resource(pdev, IORESOURCE_MEM, 0); region = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(region->start, (region->end - region->start) + 1); release_mem_region(region->start, resource_size(region));
iounmap(mmio); iounmap(mmio);
region = platform_get_resource(pdev, IORESOURCE_IO, 0); region = platform_get_resource(pdev, IORESOURCE_IO, 0);
release_mem_region(region->start, (region->end - region->start) + 1); release_mem_region(region->start, resource_size(region));
} }
static struct platform_driver s6000_i2s_driver = { static struct platform_driver s6000_i2s_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment