aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x/psc-ac97.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2011-10-18 11:06:39 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-22 05:46:35 -0400
commit226d0f22d044f0151287bb7cf334b85182248f0e (patch)
treec85786a71a405d3c1a1c0d96a685d460d9d649d5 /sound/soc/au1x/psc-ac97.c
parent33cb92cff9568dd9feb2825bd3605bf099bc6b63 (diff)
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/psc-ac97.c')
-rw-r--r--sound/soc/au1x/psc-ac97.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c
index 172eefd38b2d..0c6acd547141 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 = {
364static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev) 364static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
365{ 365{
366 int ret; 366 int ret;
367 struct resource *r; 367 struct resource *iores, *dmares;
368 unsigned long sel; 368 unsigned long sel;
369 struct au1xpsc_audio_data *wd; 369 struct au1xpsc_audio_data *wd;
370 370
@@ -374,29 +374,30 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
374 374
375 mutex_init(&wd->lock); 375 mutex_init(&wd->lock);
376 376
377 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 377 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
378 if (!r) { 378 if (!iores) {
379 ret = -ENODEV; 379 ret = -ENODEV;
380 goto out0; 380 goto out0;
381 } 381 }
382 382
383 ret = -EBUSY; 383 ret = -EBUSY;
384 if (!request_mem_region(r->start, resource_size(r), pdev->name)) 384 if (!request_mem_region(iores->start, resource_size(iores),
385 pdev->name))
385 goto out0; 386 goto out0;
386 387
387 wd->mmio = ioremap(r->start, resource_size(r)); 388 wd->mmio = ioremap(iores->start, resource_size(iores));
388 if (!wd->mmio) 389 if (!wd->mmio)
389 goto out1; 390 goto out1;
390 391
391 r = platform_get_resource(pdev, IORESOURCE_DMA, 0); 392 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
392 if (!r) 393 if (!dmares)
393 goto out2; 394 goto out2;
394 wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; 395 wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start;
395 396
396 r = platform_get_resource(pdev, IORESOURCE_DMA, 1); 397 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1);
397 if (!r) 398 if (!dmares)
398 goto out2; 399 goto out2;
399 wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; 400 wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start;
400 401
401 /* configuration: max dma trigger threshold, enable ac97 */ 402 /* configuration: max dma trigger threshold, enable ac97 */
402 wd->cfg = PSC_AC97CFG_RT_FIFO8 | PSC_AC97CFG_TT_FIFO8 | 403 wd->cfg = PSC_AC97CFG_RT_FIFO8 | PSC_AC97CFG_TT_FIFO8 |
@@ -428,7 +429,7 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
428out2: 429out2:
429 iounmap(wd->mmio); 430 iounmap(wd->mmio);
430out1: 431out1:
431 release_mem_region(r->start, resource_size(r)); 432 release_mem_region(iores->start, resource_size(iores));
432out0: 433out0:
433 kfree(wd); 434 kfree(wd);
434 return ret; 435 return ret;