diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2012-07-27 13:32:10 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-08-03 18:03:59 -0400 |
commit | ad3ab1bba9bf3fcd13a4e3f868a438013174dcc1 (patch) | |
tree | cf7cf0c644da357f44acd7e04f4c17fd67869cd3 /sound/soc/fsl | |
parent | 02286190f3ec86f03025a60c4d3f747ff1047248 (diff) |
ASoC: imx-ssi: Use devm functions
Using devm_ functions can make the code simpler and smaller.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/imx-ssi.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 28dd76c7cb1c..e174c1767c2d 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c | |||
@@ -523,7 +523,7 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
523 | int ret = 0; | 523 | int ret = 0; |
524 | struct snd_soc_dai_driver *dai; | 524 | struct snd_soc_dai_driver *dai; |
525 | 525 | ||
526 | ssi = kzalloc(sizeof(*ssi), GFP_KERNEL); | 526 | ssi = devm_kzalloc(&pdev->dev, sizeof(*ssi), GFP_KERNEL); |
527 | if (!ssi) | 527 | if (!ssi) |
528 | return -ENOMEM; | 528 | return -ENOMEM; |
529 | dev_set_drvdata(&pdev->dev, ssi); | 529 | dev_set_drvdata(&pdev->dev, ssi); |
@@ -536,7 +536,7 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
536 | 536 | ||
537 | ssi->irq = platform_get_irq(pdev, 0); | 537 | ssi->irq = platform_get_irq(pdev, 0); |
538 | 538 | ||
539 | ssi->clk = clk_get(&pdev->dev, NULL); | 539 | ssi->clk = devm_clk_get(&pdev->dev, NULL); |
540 | if (IS_ERR(ssi->clk)) { | 540 | if (IS_ERR(ssi->clk)) { |
541 | ret = PTR_ERR(ssi->clk); | 541 | ret = PTR_ERR(ssi->clk); |
542 | dev_err(&pdev->dev, "Cannot get the clock: %d\n", | 542 | dev_err(&pdev->dev, "Cannot get the clock: %d\n", |
@@ -551,23 +551,17 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
551 | goto failed_get_resource; | 551 | goto failed_get_resource; |
552 | } | 552 | } |
553 | 553 | ||
554 | if (!request_mem_region(res->start, resource_size(res), DRV_NAME)) { | 554 | ssi->base = devm_request_and_ioremap(&pdev->dev, res); |
555 | dev_err(&pdev->dev, "request_mem_region failed\n"); | ||
556 | ret = -EBUSY; | ||
557 | goto failed_get_resource; | ||
558 | } | ||
559 | |||
560 | ssi->base = ioremap(res->start, resource_size(res)); | ||
561 | if (!ssi->base) { | 555 | if (!ssi->base) { |
562 | dev_err(&pdev->dev, "ioremap failed\n"); | 556 | dev_err(&pdev->dev, "ioremap failed\n"); |
563 | ret = -ENODEV; | 557 | ret = -ENODEV; |
564 | goto failed_ioremap; | 558 | goto failed_register; |
565 | } | 559 | } |
566 | 560 | ||
567 | if (ssi->flags & IMX_SSI_USE_AC97) { | 561 | if (ssi->flags & IMX_SSI_USE_AC97) { |
568 | if (ac97_ssi) { | 562 | if (ac97_ssi) { |
569 | ret = -EBUSY; | 563 | ret = -EBUSY; |
570 | goto failed_ac97; | 564 | goto failed_register; |
571 | } | 565 | } |
572 | ac97_ssi = ssi; | 566 | ac97_ssi = ssi; |
573 | setup_channel_to_ac97(ssi); | 567 | setup_channel_to_ac97(ssi); |
@@ -636,15 +630,10 @@ failed_pdev_fiq_add: | |||
636 | failed_pdev_fiq_alloc: | 630 | failed_pdev_fiq_alloc: |
637 | snd_soc_unregister_dai(&pdev->dev); | 631 | snd_soc_unregister_dai(&pdev->dev); |
638 | failed_register: | 632 | failed_register: |
639 | failed_ac97: | ||
640 | iounmap(ssi->base); | ||
641 | failed_ioremap: | ||
642 | release_mem_region(res->start, resource_size(res)); | 633 | release_mem_region(res->start, resource_size(res)); |
643 | failed_get_resource: | 634 | failed_get_resource: |
644 | clk_disable_unprepare(ssi->clk); | 635 | clk_disable_unprepare(ssi->clk); |
645 | clk_put(ssi->clk); | ||
646 | failed_clk: | 636 | failed_clk: |
647 | kfree(ssi); | ||
648 | 637 | ||
649 | return ret; | 638 | return ret; |
650 | } | 639 | } |
@@ -662,11 +651,8 @@ static int __devexit imx_ssi_remove(struct platform_device *pdev) | |||
662 | if (ssi->flags & IMX_SSI_USE_AC97) | 651 | if (ssi->flags & IMX_SSI_USE_AC97) |
663 | ac97_ssi = NULL; | 652 | ac97_ssi = NULL; |
664 | 653 | ||
665 | iounmap(ssi->base); | ||
666 | release_mem_region(res->start, resource_size(res)); | 654 | release_mem_region(res->start, resource_size(res)); |
667 | clk_disable_unprepare(ssi->clk); | 655 | clk_disable_unprepare(ssi->clk); |
668 | clk_put(ssi->clk); | ||
669 | kfree(ssi); | ||
670 | 656 | ||
671 | return 0; | 657 | return 0; |
672 | } | 658 | } |