Skip to contentSkip to conversation

ASoC/au1x: use resource_size for au1x

PATCH Applied Wan ZongShun 3 participants 4 messages Jun 2, 2010 – Jun 3, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi mark,

How about this patch?
Applied?

Quoted 124 lines · 在 2010年6月1日 下午3:16,Wan ZongShun <[email protected]> 写道:

Dear all,

Use the resource_size function instead of manually calculating the resource size.This patch can reduce the chance of introducing off-by-one errors.

Thanks!

---
 sound/soc/au1x/psc-ac97.c |   13 +++++--------
 sound/soc/au1x/psc-i2s.c  |   13 +++++--------
 sound/soc/au1x/psc.h      |    1 -

 3 files changed, 10 insertions(+), 17 deletions(-)
sound/soc/au1x/psc-ac97.c +2 -4
index a61ccd2..d14a5a9 100644
@@ -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;
 
@@ -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;

sound/soc/au1x/psc-ac97.c +2 -2
@@ -420,6 +417,7 @@ out0:
  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);
@@ -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 */

sound/soc/au1x/psc-i2s.c +2 -4
index 495be6e..737b238 100644
@@ -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;

sound/soc/au1x/psc-i2s.c +2 -2
@@ -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 */

sound/soc/au1x/psc.h +0 -2
index 32d3807..093775d 100644
@@ -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;
  };
--

1.6.3.3

Signature · 14 lines
*linux-arm-kernel mailing list
mail addr:[email protected]
you can subscribe by:
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

* linux-arm-NUC900 mailing list
mail addr:[email protected]
main web: https://groups.google.com/group/NUC900
you can subscribe it by sending me mail:
[email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#2 lore raw
Quoted 2 lines · Wan ZongShun

How about this patch?
Applied?

I was waiting for review from Manuel.

Applied
#4 lore raw
Quoted 4 lines · Manuel Lauss
Quoted 2 lines · Mark Brown

On Wed, Jun 02, 2010 at 10:48:27PM +0800, Wan ZongShun wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

How about this patch?
Applied?

I was waiting for review from Manuel.

Oh, sorry.

Applied, thanks.