diff options
author | Julia Lawall <julia@diku.dk> | 2011-10-18 17:06:39 +0200 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-10-22 10:46:35 +0100 |
commit | 226d0f22d044f0151287bb7cf334b85182248f0e (patch) | |
tree | c85786a71a405d3c1a1c0d96a685d460d9d649d5 /sound/soc/au1x | |
parent | 33cb92cff9568dd9feb2825bd3605bf099bc6b63 (diff) | |
download | linux-3.10-226d0f22d044f0151287bb7cf334b85182248f0e.tar.gz linux-3.10-226d0f22d044f0151287bb7cf334b85182248f0e.tar.bz2 linux-3.10-226d0f22d044f0151287bb7cf334b85182248f0e.zip |
ASoC: keep pointer to resource so it can be freed
Add a new variable for storing resources accessed subsequent to the one
accessed using request_mem_region, so the one accessed using
request_mem_region can be released if needed.
The resource variable names are also changed to be more descriptive.
This code is also missing some calls to iounmap.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r@
expression E, E1;
identifier f;
statement S1,S2,S3;
@@
if (E == NULL)
{
... when != if (E == NULL || ...) S1 else S2
when != E = E1
*E->f
... when any
return ...;
}
else S3
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/au1x')
-rw-r--r-- | sound/soc/au1x/ac97c.c | 33 | ||||
-rw-r--r-- | sound/soc/au1x/i2sc.c | 33 | ||||
-rw-r--r-- | sound/soc/au1x/psc-ac97.c | 25 | ||||
-rw-r--r-- | sound/soc/au1x/psc-i2s.c | 25 |
4 files changed, 62 insertions, 54 deletions
diff --git a/sound/soc/au1x/ac97c.c b/sound/soc/au1x/ac97c.c index 13802ff7cf0..726bd651a10 100644 --- a/sound/soc/au1x/ac97c.c +++ b/sound/soc/au1x/ac97c.c @@ -226,7 +226,7 @@ static struct snd_soc_dai_driver au1xac97c_dai_driver = { static int __devinit au1xac97c_drvprobe(struct platform_device *pdev) { int ret; - struct resource *r; + struct resource *iores, *dmares; struct au1xpsc_audio_data *ctx; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); @@ -235,29 +235,30 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev) mutex_init(&ctx->lock); - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) { + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!iores) { ret = -ENODEV; goto out0; } ret = -EBUSY; - if (!request_mem_region(r->start, resource_size(r), pdev->name)) + if (!request_mem_region(iores->start, resource_size(iores), + pdev->name)) goto out0; - ctx->mmio = ioremap_nocache(r->start, resource_size(r)); + ctx->mmio = ioremap_nocache(iores->start, resource_size(iores)); if (!ctx->mmio) goto out1; - r = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!r) - goto out1; - ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); + if (!dmares) + goto out2; + ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; - r = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!r) - goto out1; - ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (!dmares) + goto out2; + ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; /* switch it on */ WR(ctx, AC97_ENABLE, EN_D | EN_CE); @@ -270,13 +271,15 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev) ret = snd_soc_register_dai(&pdev->dev, &au1xac97c_dai_driver); if (ret) - goto out1; + goto out2; ac97c_workdata = ctx; return 0; +out2: + iounmap(ctx->mmio); out1: - release_mem_region(r->start, resource_size(r)); + release_mem_region(iores->start, resource_size(iores)); out0: kfree(ctx); return ret; diff --git a/sound/soc/au1x/i2sc.c b/sound/soc/au1x/i2sc.c index 19e0d2a9c82..6bcf48f5884 100644 --- a/sound/soc/au1x/i2sc.c +++ b/sound/soc/au1x/i2sc.c @@ -228,47 +228,50 @@ static struct snd_soc_dai_driver au1xi2s_dai_driver = { static int __devinit au1xi2s_drvprobe(struct platform_device *pdev) { int ret; - struct resource *r; + struct resource *iores, *dmares; struct au1xpsc_audio_data *ctx; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) { + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!iores) { ret = -ENODEV; goto out0; } ret = -EBUSY; - if (!request_mem_region(r->start, resource_size(r), pdev->name)) + if (!request_mem_region(iores->start, resource_size(iores), + pdev->name)) goto out0; - ctx->mmio = ioremap_nocache(r->start, resource_size(r)); + ctx->mmio = ioremap_nocache(iores->start, resource_size(iores)); if (!ctx->mmio) goto out1; - r = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!r) - goto out1; - ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); + if (!dmares) + goto out2; + ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; - r = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!r) - goto out1; - ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (!dmares) + goto out2; + ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; platform_set_drvdata(pdev, ctx); ret = snd_soc_register_dai(&pdev->dev, &au1xi2s_dai_driver); if (ret) - goto out1; + goto out2; return 0; +out2: + iounmap(ctx->mmio); out1: - release_mem_region(r->start, resource_size(r)); + release_mem_region(iores->start, resource_size(iores)); out0: kfree(ctx); return ret; diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c index 172eefd38b2..0c6acd54714 100644 --- a/sound/soc/au1x/psc-ac97.c +++ b/sound/soc/au1x/psc-ac97.c @@ -364,7 +364,7 @@ static const struct snd_soc_dai_driver au1xpsc_ac97_dai_template = { static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev) { int ret; - struct resource *r; + struct resource *iores, *dmares; unsigned long sel; struct au1xpsc_audio_data *wd; @@ -374,29 +374,30 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev) mutex_init(&wd->lock); - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) { + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!iores) { ret = -ENODEV; goto out0; } ret = -EBUSY; - if (!request_mem_region(r->start, resource_size(r), pdev->name)) + if (!request_mem_region(iores->start, resource_size(iores), + pdev->name)) goto out0; - wd->mmio = ioremap(r->start, resource_size(r)); + wd->mmio = ioremap(iores->start, resource_size(iores)); if (!wd->mmio) goto out1; - r = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!r) + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); + if (!dmares) goto out2; - wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; + wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; - r = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!r) + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (!dmares) goto out2; - wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; + wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; /* configuration: max dma trigger threshold, enable ac97 */ wd->cfg = PSC_AC97CFG_RT_FIFO8 | PSC_AC97CFG_TT_FIFO8 | @@ -428,7 +429,7 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev) out2: iounmap(wd->mmio); out1: - release_mem_region(r->start, resource_size(r)); + release_mem_region(iores->start, resource_size(iores)); out0: kfree(wd); return ret; diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c index 7c5ae920544..e03c5ce01b3 100644 --- a/sound/soc/au1x/psc-i2s.c +++ b/sound/soc/au1x/psc-i2s.c @@ -290,7 +290,7 @@ static const struct snd_soc_dai_driver au1xpsc_i2s_dai_template = { static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev) { - struct resource *r; + struct resource *iores, *dmares; unsigned long sel; int ret; struct au1xpsc_audio_data *wd; @@ -299,29 +299,30 @@ static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev) if (!wd) return -ENOMEM; - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) { + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!iores) { ret = -ENODEV; goto out0; } ret = -EBUSY; - if (!request_mem_region(r->start, resource_size(r), pdev->name)) + if (!request_mem_region(iores->start, resource_size(iores), + pdev->name)) goto out0; - wd->mmio = ioremap(r->start, resource_size(r)); + wd->mmio = ioremap(iores->start, resource_size(iores)); if (!wd->mmio) goto out1; - r = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!r) + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); + if (!dmares) goto out2; - wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; + wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; - r = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!r) + dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (!dmares) goto out2; - wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; + wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; /* preserve PSC clock source set up by platform (dev.platform_data * is already occupied by soc layer) @@ -355,7 +356,7 @@ static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev) out2: iounmap(wd->mmio); out1: - release_mem_region(r->start, resource_size(r)); + release_mem_region(iores->start, resource_size(iores)); out0: kfree(wd); return ret; |