aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x
diff options
context:
space:
mode:
authorJulia Lawall <julia.lawall@lip6.fr>2011-12-29 11:51:25 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-01-02 08:08:07 -0500
commit8d9626d72833bf68791e4cf9ac151c96c44c0f87 (patch)
treeec7c058f42c4b679ac70dbdfd56366935888e33a /sound/soc/au1x
parentaa4079c110133e5ed86895a07bffb20dd20ed40e (diff)
ASoC: psc-ac97.c: use devm_ functions
The various devm_ functions allocate memory that is released when a driver detaches. This patch uses devm_kzalloc, devm_request_mem_region and devm_ioremap for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/au1x')
-rw-r--r--sound/soc/au1x/psc-ac97.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c
index 87daf456b1c9..476b79a1c11a 100644
--- a/sound/soc/au1x/psc-ac97.c
+++ b/sound/soc/au1x/psc-ac97.c
@@ -368,35 +368,35 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
368 unsigned long sel; 368 unsigned long sel;
369 struct au1xpsc_audio_data *wd; 369 struct au1xpsc_audio_data *wd;
370 370
371 wd = kzalloc(sizeof(struct au1xpsc_audio_data), GFP_KERNEL); 371 wd = devm_kzalloc(&pdev->dev, sizeof(struct au1xpsc_audio_data),
372 GFP_KERNEL);
372 if (!wd) 373 if (!wd)
373 return -ENOMEM; 374 return -ENOMEM;
374 375
375 mutex_init(&wd->lock); 376 mutex_init(&wd->lock);
376 377
377 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 378 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
378 if (!iores) { 379 if (!iores)
379 ret = -ENODEV; 380 return -ENODEV;
380 goto out0;
381 }
382 381
383 ret = -EBUSY; 382 if (!devm_request_mem_region(&pdev->dev, iores->start,
384 if (!request_mem_region(iores->start, resource_size(iores), 383 resource_size(iores),
385 pdev->name)) 384 pdev->name))
386 goto out0; 385 return -EBUSY;
387 386
388 wd->mmio = ioremap(iores->start, resource_size(iores)); 387 wd->mmio = devm_ioremap(&pdev->dev, iores->start,
388 resource_size(iores));
389 if (!wd->mmio) 389 if (!wd->mmio)
390 goto out1; 390 return -EBUSY;
391 391
392 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); 392 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
393 if (!dmares) 393 if (!dmares)
394 goto out2; 394 return -EBUSY;
395 wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; 395 wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start;
396 396
397 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); 397 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1);
398 if (!dmares) 398 if (!dmares)
399 goto out2; 399 return -EBUSY;
400 wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; 400 wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start;
401 401
402 /* configuration: max dma trigger threshold, enable ac97 */ 402 /* configuration: max dma trigger threshold, enable ac97 */
@@ -421,24 +421,15 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
421 421
422 ret = snd_soc_register_dai(&pdev->dev, &wd->dai_drv); 422 ret = snd_soc_register_dai(&pdev->dev, &wd->dai_drv);
423 if (ret) 423 if (ret)
424 goto out2; 424 return ret;
425 425
426 au1xpsc_ac97_workdata = wd; 426 au1xpsc_ac97_workdata = wd;
427 return 0; 427 return 0;
428
429out2:
430 iounmap(wd->mmio);
431out1:
432 release_mem_region(iores->start, resource_size(iores));
433out0:
434 kfree(wd);
435 return ret;
436} 428}
437 429
438static int __devexit au1xpsc_ac97_drvremove(struct platform_device *pdev) 430static int __devexit au1xpsc_ac97_drvremove(struct platform_device *pdev)
439{ 431{
440 struct au1xpsc_audio_data *wd = platform_get_drvdata(pdev); 432 struct au1xpsc_audio_data *wd = platform_get_drvdata(pdev);
441 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
442 433
443 snd_soc_unregister_dai(&pdev->dev); 434 snd_soc_unregister_dai(&pdev->dev);
444 435
@@ -448,10 +439,6 @@ static int __devexit au1xpsc_ac97_drvremove(struct platform_device *pdev)
448 au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); 439 au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd));
449 au_sync(); 440 au_sync();
450 441
451 iounmap(wd->mmio);
452 release_mem_region(r->start, resource_size(r));
453 kfree(wd);
454
455 au1xpsc_ac97_workdata = NULL; /* MDEV */ 442 au1xpsc_ac97_workdata = NULL; /* MDEV */
456 443
457 return 0; 444 return 0;