aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x
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
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')
-rw-r--r--sound/soc/au1x/ac97c.c33
-rw-r--r--sound/soc/au1x/i2sc.c33
-rw-r--r--sound/soc/au1x/psc-ac97.c25
-rw-r--r--sound/soc/au1x/psc-i2s.c25
4 files changed, 62 insertions, 54 deletions
diff --git a/sound/soc/au1x/ac97c.c b/sound/soc/au1x/ac97c.c
index 13802ff7cf05..726bd651a105 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 = {
226static int __devinit au1xac97c_drvprobe(struct platform_device *pdev) 226static int __devinit au1xac97c_drvprobe(struct platform_device *pdev)
227{ 227{
228 int ret; 228 int ret;
229 struct resource *r; 229 struct resource *iores, *dmares;
230 struct au1xpsc_audio_data *ctx; 230 struct au1xpsc_audio_data *ctx;
231 231
232 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 232 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -235,29 +235,30 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev)
235 235
236 mutex_init(&ctx->lock); 236 mutex_init(&ctx->lock);
237 237
238 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 238 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
239 if (!r) { 239 if (!iores) {
240 ret = -ENODEV; 240 ret = -ENODEV;
241 goto out0; 241 goto out0;
242 } 242 }
243 243
244 ret = -EBUSY; 244 ret = -EBUSY;
245 if (!request_mem_region(r->start, resource_size(r), pdev->name)) 245 if (!request_mem_region(iores->start, resource_size(iores),
246 pdev->name))
246 goto out0; 247 goto out0;
247 248
248 ctx->mmio = ioremap_nocache(r->start, resource_size(r)); 249 ctx->mmio = ioremap_nocache(iores->start, resource_size(iores));
249 if (!ctx->mmio) 250 if (!ctx->mmio)
250 goto out1; 251 goto out1;
251 252
252 r = platform_get_resource(pdev, IORESOURCE_DMA, 0); 253 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
253 if (!r) 254 if (!dmares)
254 goto out1; 255 goto out2;
255 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; 256 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start;
256 257
257 r = platform_get_resource(pdev, IORESOURCE_DMA, 1); 258 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1);
258 if (!r) 259 if (!dmares)
259 goto out1; 260 goto out2;
260 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; 261 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start;
261 262
262 /* switch it on */ 263 /* switch it on */
263 WR(ctx, AC97_ENABLE, EN_D | EN_CE); 264 WR(ctx, AC97_ENABLE, EN_D | EN_CE);
@@ -270,13 +271,15 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev)
270 271
271 ret = snd_soc_register_dai(&pdev->dev, &au1xac97c_dai_driver); 272 ret = snd_soc_register_dai(&pdev->dev, &au1xac97c_dai_driver);
272 if (ret) 273 if (ret)
273 goto out1; 274 goto out2;
274 275
275 ac97c_workdata = ctx; 276 ac97c_workdata = ctx;
276 return 0; 277 return 0;
277 278
279out2:
280 iounmap(ctx->mmio);
278out1: 281out1:
279 release_mem_region(r->start, resource_size(r)); 282 release_mem_region(iores->start, resource_size(iores));
280out0: 283out0:
281 kfree(ctx); 284 kfree(ctx);
282 return ret; 285 return ret;
diff --git a/sound/soc/au1x/i2sc.c b/sound/soc/au1x/i2sc.c
index 19e0d2a9c828..6bcf48f5884c 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 = {
228static int __devinit au1xi2s_drvprobe(struct platform_device *pdev) 228static int __devinit au1xi2s_drvprobe(struct platform_device *pdev)
229{ 229{
230 int ret; 230 int ret;
231 struct resource *r; 231 struct resource *iores, *dmares;
232 struct au1xpsc_audio_data *ctx; 232 struct au1xpsc_audio_data *ctx;
233 233
234 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 234 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
235 if (!ctx) 235 if (!ctx)
236 return -ENOMEM; 236 return -ENOMEM;
237 237
238 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 238 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
239 if (!r) { 239 if (!iores) {
240 ret = -ENODEV; 240 ret = -ENODEV;
241 goto out0; 241 goto out0;
242 } 242 }
243 243
244 ret = -EBUSY; 244 ret = -EBUSY;
245 if (!request_mem_region(r->start, resource_size(r), pdev->name)) 245 if (!request_mem_region(iores->start, resource_size(iores),
246 pdev->name))
246 goto out0; 247 goto out0;
247 248
248 ctx->mmio = ioremap_nocache(r->start, resource_size(r)); 249 ctx->mmio = ioremap_nocache(iores->start, resource_size(iores));
249 if (!ctx->mmio) 250 if (!ctx->mmio)
250 goto out1; 251 goto out1;
251 252
252 r = platform_get_resource(pdev, IORESOURCE_DMA, 0); 253 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
253 if (!r) 254 if (!dmares)
254 goto out1; 255 goto out2;
255 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = r->start; 256 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start;
256 257
257 r = platform_get_resource(pdev, IORESOURCE_DMA, 1); 258 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1);
258 if (!r) 259 if (!dmares)
259 goto out1; 260 goto out2;
260 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = r->start; 261 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start;
261 262
262 platform_set_drvdata(pdev, ctx); 263 platform_set_drvdata(pdev, ctx);
263 264
264 ret = snd_soc_register_dai(&pdev->dev, &au1xi2s_dai_driver); 265 ret = snd_soc_register_dai(&pdev->dev, &au1xi2s_dai_driver);
265 if (ret) 266 if (ret)
266 goto out1; 267 goto out2;
267 268
268 return 0; 269 return 0;
269 270
271out2:
272 iounmap(ctx->mmio);
270out1: 273out1:
271 release_mem_region(r->start, resource_size(r)); 274 release_mem_region(iores->start, resource_size(iores));
272out0: 275out0:
273 kfree(ctx); 276 kfree(ctx);
274 return ret; 277 return ret;
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;
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;