From c0da5500e9962e23ee8bb0bce9cb4307d44c0ae7 Mon Sep 17 00:00:00 2001 From: Wan ZongShun Date: Tue, 1 Jun 2010 15:16:20 +0800 Subject: ASoC: use resource_size for au1x 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 Acked-by: Manuel Lauss Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/au1x/psc-i2s.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'sound/soc/au1x/psc-i2s.c') diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c index 495be6e..737b238 100644 --- a/sound/soc/au1x/psc-i2s.c +++ b/sound/soc/au1x/psc-i2s.c @@ -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; @@ -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; @@ -372,6 +369,7 @@ out0: 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); @@ -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 */ -- cgit v1.1