diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-07-23 05:39:51 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-03 18:03:55 -0400 |
commit | d77ae3329292baebfc6eced97d2e12b66349f83c (patch) | |
tree | 3a6289444f03af5b4be3b464bea31b2e45537f61 /sound/soc | |
parent | 3c6c2a997743c48c3ef8abbf3400c4cf6da650fe (diff) |
ASoC: omap-mcpdm: Convert to use devm_*
Switch to use devm_* te make the probe/remove code more cleaner.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/omap/omap-mcpdm.c | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 2c66e2498a45..f7babb374a37 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -445,9 +445,8 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) | |||
445 | { | 445 | { |
446 | struct omap_mcpdm *mcpdm; | 446 | struct omap_mcpdm *mcpdm; |
447 | struct resource *res; | 447 | struct resource *res; |
448 | int ret = 0; | ||
449 | 448 | ||
450 | mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL); | 449 | mcpdm = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcpdm), GFP_KERNEL); |
451 | if (!mcpdm) | 450 | if (!mcpdm) |
452 | return -ENOMEM; | 451 | return -ENOMEM; |
453 | 452 | ||
@@ -456,55 +455,30 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) | |||
456 | mutex_init(&mcpdm->mutex); | 455 | mutex_init(&mcpdm->mutex); |
457 | 456 | ||
458 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 457 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
459 | if (res == NULL) { | 458 | if (res == NULL) |
460 | dev_err(&pdev->dev, "no resource\n"); | 459 | return -ENOMEM; |
461 | goto err_res; | ||
462 | } | ||
463 | 460 | ||
464 | if (!request_mem_region(res->start, resource_size(res), "McPDM")) { | 461 | if (!devm_request_mem_region(&pdev->dev, res->start, |
465 | ret = -EBUSY; | 462 | resource_size(res), "McPDM")) |
466 | goto err_res; | 463 | return -EBUSY; |
467 | } | ||
468 | 464 | ||
469 | mcpdm->io_base = ioremap(res->start, resource_size(res)); | 465 | mcpdm->io_base = devm_ioremap(&pdev->dev, res->start, |
470 | if (!mcpdm->io_base) { | 466 | resource_size(res)); |
471 | ret = -ENOMEM; | 467 | if (!mcpdm->io_base) |
472 | goto err_iomap; | 468 | return -ENOMEM; |
473 | } | ||
474 | 469 | ||
475 | mcpdm->irq = platform_get_irq(pdev, 0); | 470 | mcpdm->irq = platform_get_irq(pdev, 0); |
476 | if (mcpdm->irq < 0) { | 471 | if (mcpdm->irq < 0) |
477 | ret = mcpdm->irq; | 472 | return mcpdm->irq; |
478 | goto err_irq; | ||
479 | } | ||
480 | 473 | ||
481 | mcpdm->dev = &pdev->dev; | 474 | mcpdm->dev = &pdev->dev; |
482 | 475 | ||
483 | ret = snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai); | 476 | return snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai); |
484 | if (!ret) | ||
485 | return 0; | ||
486 | |||
487 | err_irq: | ||
488 | iounmap(mcpdm->io_base); | ||
489 | err_iomap: | ||
490 | release_mem_region(res->start, resource_size(res)); | ||
491 | err_res: | ||
492 | kfree(mcpdm); | ||
493 | return ret; | ||
494 | } | 477 | } |
495 | 478 | ||
496 | static int __devexit asoc_mcpdm_remove(struct platform_device *pdev) | 479 | static int __devexit asoc_mcpdm_remove(struct platform_device *pdev) |
497 | { | 480 | { |
498 | struct omap_mcpdm *mcpdm = platform_get_drvdata(pdev); | ||
499 | struct resource *res; | ||
500 | |||
501 | snd_soc_unregister_dai(&pdev->dev); | 481 | snd_soc_unregister_dai(&pdev->dev); |
502 | |||
503 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
504 | iounmap(mcpdm->io_base); | ||
505 | release_mem_region(res->start, resource_size(res)); | ||
506 | |||
507 | kfree(mcpdm); | ||
508 | return 0; | 482 | return 0; |
509 | } | 483 | } |
510 | 484 | ||