diff options
author | Julia Lawall <julia.lawall@lip6.fr> | 2011-12-29 11:51:24 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-02 08:08:02 -0500 |
commit | aa4079c110133e5ed86895a07bffb20dd20ed40e (patch) | |
tree | be8136dfc3e36ec6eb012df3fb02bdbd6422e63b | |
parent | cd0ff7eff08e7daeba278cf58392aac519edff60 (diff) |
ASoC: psc-i2s.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>
-rw-r--r-- | sound/soc/au1x/psc-i2s.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c index 5c1dc8a141ab..0607ba3d9258 100644 --- a/sound/soc/au1x/psc-i2s.c +++ b/sound/soc/au1x/psc-i2s.c | |||
@@ -295,33 +295,34 @@ static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev) | |||
295 | int ret; | 295 | int ret; |
296 | struct au1xpsc_audio_data *wd; | 296 | struct au1xpsc_audio_data *wd; |
297 | 297 | ||
298 | wd = kzalloc(sizeof(struct au1xpsc_audio_data), GFP_KERNEL); | 298 | wd = devm_kzalloc(&pdev->dev, sizeof(struct au1xpsc_audio_data), |
299 | GFP_KERNEL); | ||
299 | if (!wd) | 300 | if (!wd) |
300 | return -ENOMEM; | 301 | return -ENOMEM; |
301 | 302 | ||
302 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 303 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
303 | if (!iores) { | 304 | if (!iores) |
304 | ret = -ENODEV; | 305 | return -ENODEV; |
305 | goto out0; | ||
306 | } | ||
307 | 306 | ||
308 | ret = -EBUSY; | 307 | ret = -EBUSY; |
309 | if (!request_mem_region(iores->start, resource_size(iores), | 308 | if (!devm_request_mem_region(&pdev->dev, iores->start, |
310 | pdev->name)) | 309 | resource_size(iores), |
311 | goto out0; | 310 | pdev->name)) |
311 | return -EBUSY; | ||
312 | 312 | ||
313 | wd->mmio = ioremap(iores->start, resource_size(iores)); | 313 | wd->mmio = devm_ioremap(&pdev->dev, iores->start, |
314 | resource_size(iores)); | ||
314 | if (!wd->mmio) | 315 | if (!wd->mmio) |
315 | goto out1; | 316 | return -EBUSY; |
316 | 317 | ||
317 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 318 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
318 | if (!dmares) | 319 | if (!dmares) |
319 | goto out2; | 320 | return -EBUSY; |
320 | wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; | 321 | wd->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; |
321 | 322 | ||
322 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); | 323 | dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); |
323 | if (!dmares) | 324 | if (!dmares) |
324 | goto out2; | 325 | return -EBUSY; |
325 | wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; | 326 | wd->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; |
326 | 327 | ||
327 | /* preserve PSC clock source set up by platform (dev.platform_data | 328 | /* preserve PSC clock source set up by platform (dev.platform_data |
@@ -349,23 +350,12 @@ static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev) | |||
349 | 350 | ||
350 | platform_set_drvdata(pdev, wd); | 351 | platform_set_drvdata(pdev, wd); |
351 | 352 | ||
352 | ret = snd_soc_register_dai(&pdev->dev, &wd->dai_drv); | 353 | return snd_soc_register_dai(&pdev->dev, &wd->dai_drv); |
353 | if (!ret) | ||
354 | return 0; | ||
355 | |||
356 | out2: | ||
357 | iounmap(wd->mmio); | ||
358 | out1: | ||
359 | release_mem_region(iores->start, resource_size(iores)); | ||
360 | out0: | ||
361 | kfree(wd); | ||
362 | return ret; | ||
363 | } | 354 | } |
364 | 355 | ||
365 | static int __devexit au1xpsc_i2s_drvremove(struct platform_device *pdev) | 356 | static int __devexit au1xpsc_i2s_drvremove(struct platform_device *pdev) |
366 | { | 357 | { |
367 | struct au1xpsc_audio_data *wd = platform_get_drvdata(pdev); | 358 | struct au1xpsc_audio_data *wd = platform_get_drvdata(pdev); |
368 | struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
369 | 359 | ||
370 | snd_soc_unregister_dai(&pdev->dev); | 360 | snd_soc_unregister_dai(&pdev->dev); |
371 | 361 | ||
@@ -374,10 +364,6 @@ static int __devexit au1xpsc_i2s_drvremove(struct platform_device *pdev) | |||
374 | au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); | 364 | au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd)); |
375 | au_sync(); | 365 | au_sync(); |
376 | 366 | ||
377 | iounmap(wd->mmio); | ||
378 | release_mem_region(r->start, resource_size(r)); | ||
379 | kfree(wd); | ||
380 | |||
381 | return 0; | 367 | return 0; |
382 | } | 368 | } |
383 | 369 | ||