aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x/psc-i2s.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-i2s.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-i2s.c')
-rw-r--r--sound/soc/au1x/psc-i2s.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c
index 7c5ae920544f..e03c5ce01b30 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 = {
290 290
291static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev) 291static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev)
292{ 292{
293 struct resource *r; 293 struct resource *iores, *dmares;
294 unsigned long sel; 294 unsigned long sel;
295 int ret; 295 int ret;
296 struct au1xpsc_audio_data *wd; 296 struct au1xpsc_audio_data *wd;
@@ -299,29 +299,30 @@ static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev)
299 if (!wd) 299 if (!wd)
300 return -ENOMEM; 300 return -ENOMEM;
301 301
302 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 302 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
303 if (!r) { 303 if (!iores) {
304 ret = -ENODEV; 304 ret = -ENODEV;
305 goto out0; 305 goto out0;
306 } 306 }
307 307
308 ret = -EBUSY; 308 ret = -EBUSY;
309 if (!request_mem_region(r->start, resource_size(r), pdev->name)) 309 if (!request_mem_region(iores->start, resource_size(iores),
310 pdev->name))
310 goto out0; 311 goto out0;
311 312
312 wd->mmio = ioremap(r->start, resource_size(r)); 313 wd->mmio = ioremap(iores->start, resource_size(iores));
313 if (!wd->mmio) 314 if (!wd->mmio)
314 goto out1; 315 goto out1;
315 316
316 r = platform_get_resource(pdev, IORESOURCE_DMA, 0); 317 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
317 if (!r) 318 if (!dmares)
318 goto out2; 319 goto out2;
319 wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; 320 wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start;
320 321
321 r = platform_get_resource(pdev, IORESOURCE_DMA, 1); 322 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1);
322 if (!r) 323 if (!dmares)
323 goto out2; 324 goto out2;
324 wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; 325 wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start;
325 326
326 /* preserve PSC clock source set up by platform (dev.platform_data 327 /* preserve PSC clock source set up by platform (dev.platform_data
327 * is already occupied by soc layer) 328 * is already occupied by soc layer)
@@ -355,7 +356,7 @@ static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev)
355out2: 356out2:
356 iounmap(wd->mmio); 357 iounmap(wd->mmio);
357out1: 358out1:
358 release_mem_region(r->start, resource_size(r)); 359 release_mem_region(iores->start, resource_size(iores));
359out0: 360out0:
360 kfree(wd); 361 kfree(wd);
361 return ret; 362 return ret;