Skip to content

Commit

Permalink
ASoC: use resource_size for au1x
Browse files Browse the repository at this point in the history
Use the resource_size function instead of manually calculating the
resource size.This patch can reduce the chance of introducing off-by-one
errors.

Signed-off-by: Wan ZongShun <mcuos.com@gmail.com>
Acked-by: Manuel Lauss <manuel.lauss@googlemail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Wan ZongShun authored and Mark Brown committed Jun 3, 2010
1 parent 5ef650a commit c0da550
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
13 changes: 5 additions & 8 deletions sound/soc/au1x/psc-ac97.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,10 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
}

ret = -EBUSY;
wd->ioarea = request_mem_region(r->start, r->end - r->start + 1,
"au1xpsc_ac97");
if (!wd->ioarea)
if (!request_mem_region(r->start, resource_size(r), pdev->name))
goto out0;

wd->mmio = ioremap(r->start, 0xffff);
wd->mmio = ioremap(r->start, resource_size(r));
if (!wd->mmio)
goto out1;

Expand Down Expand Up @@ -410,8 +408,7 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)

snd_soc_unregister_dai(&au1xpsc_ac97_dai);
out1:
release_resource(wd->ioarea);
kfree(wd->ioarea);
release_mem_region(r->start, resource_size(r));
out0:
kfree(wd);
return ret;
Expand All @@ -420,6 +417,7 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
static int __devexit au1xpsc_ac97_drvremove(struct platform_device *pdev)
{
struct au1xpsc_audio_data *wd = platform_get_drvdata(pdev);
struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);

if (wd->dmapd)
au1xpsc_pcm_destroy(wd->dmapd);
Expand All @@ -433,8 +431,7 @@ static int __devexit au1xpsc_ac97_drvremove(struct platform_device *pdev)
au_sync();

iounmap(wd->mmio);
release_resource(wd->ioarea);
kfree(wd->ioarea);
release_mem_region(r->start, resource_size(r));
kfree(wd);

au1xpsc_ac97_workdata = NULL; /* MDEV */
Expand Down
13 changes: 5 additions & 8 deletions sound/soc/au1x/psc-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,10 @@ static int __init au1xpsc_i2s_drvprobe(struct platform_device *pdev)
}

ret = -EBUSY;
wd->ioarea = request_mem_region(r->start, r->end - r->start + 1,
"au1xpsc_i2s");
if (!wd->ioarea)
if (!request_mem_region(r->start, resource_size(r), pdev->name))
goto out0;

wd->mmio = ioremap(r->start, 0xffff);
wd->mmio = ioremap(r->start, resource_size(r));
if (!wd->mmio)
goto out1;

Expand Down Expand Up @@ -362,8 +360,7 @@ static int __init au1xpsc_i2s_drvprobe(struct platform_device *pdev)

snd_soc_unregister_dai(&au1xpsc_i2s_dai);
out1:
release_resource(wd->ioarea);
kfree(wd->ioarea);
release_mem_region(r->start, resource_size(r));
out0:
kfree(wd);
return ret;
Expand All @@ -372,6 +369,7 @@ static int __init au1xpsc_i2s_drvprobe(struct platform_device *pdev)
static int __devexit au1xpsc_i2s_drvremove(struct platform_device *pdev)
{
struct au1xpsc_audio_data *wd = platform_get_drvdata(pdev);
struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);

if (wd->dmapd)
au1xpsc_pcm_destroy(wd->dmapd);
Expand All @@ -384,8 +382,7 @@ static int __devexit au1xpsc_i2s_drvremove(struct platform_device *pdev)
au_sync();

iounmap(wd->mmio);
release_resource(wd->ioarea);
kfree(wd->ioarea);
release_mem_region(r->start, resource_size(r));
kfree(wd);

au1xpsc_i2s_workdata = NULL; /* MDEV */
Expand Down
1 change: 0 additions & 1 deletion sound/soc/au1x/psc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct au1xpsc_audio_data {
unsigned long rate;

unsigned long pm[2];
struct resource *ioarea;
struct mutex lock;
struct platform_device *dmapd;
};
Expand Down

0 comments on commit c0da550

Please sign in to comment.