diff options
Diffstat (limited to 'sound/soc/davinci/davinci-mcasp.c')
-rw-r--r-- | sound/soc/davinci/davinci-mcasp.c | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 7173df254a91..95441bfc8190 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
@@ -813,7 +813,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, | |||
813 | return 0; | 813 | return 0; |
814 | } | 814 | } |
815 | 815 | ||
816 | static struct snd_soc_dai_ops davinci_mcasp_dai_ops = { | 816 | static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = { |
817 | .startup = davinci_mcasp_startup, | 817 | .startup = davinci_mcasp_startup, |
818 | .trigger = davinci_mcasp_trigger, | 818 | .trigger = davinci_mcasp_trigger, |
819 | .hw_params = davinci_mcasp_hw_params, | 819 | .hw_params = davinci_mcasp_hw_params, |
@@ -865,38 +865,35 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
865 | struct resource *mem, *ioarea, *res; | 865 | struct resource *mem, *ioarea, *res; |
866 | struct snd_platform_data *pdata; | 866 | struct snd_platform_data *pdata; |
867 | struct davinci_audio_dev *dev; | 867 | struct davinci_audio_dev *dev; |
868 | int ret = 0; | 868 | int ret; |
869 | 869 | ||
870 | dev = kzalloc(sizeof(struct davinci_audio_dev), GFP_KERNEL); | 870 | dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_audio_dev), |
871 | GFP_KERNEL); | ||
871 | if (!dev) | 872 | if (!dev) |
872 | return -ENOMEM; | 873 | return -ENOMEM; |
873 | 874 | ||
874 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 875 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
875 | if (!mem) { | 876 | if (!mem) { |
876 | dev_err(&pdev->dev, "no mem resource?\n"); | 877 | dev_err(&pdev->dev, "no mem resource?\n"); |
877 | ret = -ENODEV; | 878 | return -ENODEV; |
878 | goto err_release_data; | ||
879 | } | 879 | } |
880 | 880 | ||
881 | ioarea = request_mem_region(mem->start, | 881 | ioarea = devm_request_mem_region(&pdev->dev, mem->start, |
882 | resource_size(mem), pdev->name); | 882 | resource_size(mem), pdev->name); |
883 | if (!ioarea) { | 883 | if (!ioarea) { |
884 | dev_err(&pdev->dev, "Audio region already claimed\n"); | 884 | dev_err(&pdev->dev, "Audio region already claimed\n"); |
885 | ret = -EBUSY; | 885 | return -EBUSY; |
886 | goto err_release_data; | ||
887 | } | 886 | } |
888 | 887 | ||
889 | pdata = pdev->dev.platform_data; | 888 | pdata = pdev->dev.platform_data; |
890 | dev->clk = clk_get(&pdev->dev, NULL); | 889 | dev->clk = clk_get(&pdev->dev, NULL); |
891 | if (IS_ERR(dev->clk)) { | 890 | if (IS_ERR(dev->clk)) |
892 | ret = -ENODEV; | 891 | return -ENODEV; |
893 | goto err_release_region; | ||
894 | } | ||
895 | 892 | ||
896 | clk_enable(dev->clk); | 893 | clk_enable(dev->clk); |
897 | dev->clk_active = 1; | 894 | dev->clk_active = 1; |
898 | 895 | ||
899 | dev->base = ioremap(mem->start, resource_size(mem)); | 896 | dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); |
900 | if (!dev->base) { | 897 | if (!dev->base) { |
901 | dev_err(&pdev->dev, "ioremap failed\n"); | 898 | dev_err(&pdev->dev, "ioremap failed\n"); |
902 | ret = -ENOMEM; | 899 | ret = -ENOMEM; |
@@ -924,7 +921,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
924 | if (!res) { | 921 | if (!res) { |
925 | dev_err(&pdev->dev, "no DMA resource\n"); | 922 | dev_err(&pdev->dev, "no DMA resource\n"); |
926 | ret = -ENODEV; | 923 | ret = -ENODEV; |
927 | goto err_iounmap; | 924 | goto err_release_clk; |
928 | } | 925 | } |
929 | 926 | ||
930 | dma_data->channel = res->start; | 927 | dma_data->channel = res->start; |
@@ -940,7 +937,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
940 | if (!res) { | 937 | if (!res) { |
941 | dev_err(&pdev->dev, "no DMA resource\n"); | 938 | dev_err(&pdev->dev, "no DMA resource\n"); |
942 | ret = -ENODEV; | 939 | ret = -ENODEV; |
943 | goto err_iounmap; | 940 | goto err_release_clk; |
944 | } | 941 | } |
945 | 942 | ||
946 | dma_data->channel = res->start; | 943 | dma_data->channel = res->start; |
@@ -948,37 +945,24 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
948 | ret = snd_soc_register_dai(&pdev->dev, &davinci_mcasp_dai[pdata->op_mode]); | 945 | ret = snd_soc_register_dai(&pdev->dev, &davinci_mcasp_dai[pdata->op_mode]); |
949 | 946 | ||
950 | if (ret != 0) | 947 | if (ret != 0) |
951 | goto err_iounmap; | 948 | goto err_release_clk; |
952 | return 0; | 949 | return 0; |
953 | 950 | ||
954 | err_iounmap: | ||
955 | iounmap(dev->base); | ||
956 | err_release_clk: | 951 | err_release_clk: |
957 | clk_disable(dev->clk); | 952 | clk_disable(dev->clk); |
958 | clk_put(dev->clk); | 953 | clk_put(dev->clk); |
959 | err_release_region: | ||
960 | release_mem_region(mem->start, resource_size(mem)); | ||
961 | err_release_data: | ||
962 | kfree(dev); | ||
963 | |||
964 | return ret; | 954 | return ret; |
965 | } | 955 | } |
966 | 956 | ||
967 | static int davinci_mcasp_remove(struct platform_device *pdev) | 957 | static int davinci_mcasp_remove(struct platform_device *pdev) |
968 | { | 958 | { |
969 | struct davinci_audio_dev *dev = dev_get_drvdata(&pdev->dev); | 959 | struct davinci_audio_dev *dev = dev_get_drvdata(&pdev->dev); |
970 | struct resource *mem; | ||
971 | 960 | ||
972 | snd_soc_unregister_dai(&pdev->dev); | 961 | snd_soc_unregister_dai(&pdev->dev); |
973 | clk_disable(dev->clk); | 962 | clk_disable(dev->clk); |
974 | clk_put(dev->clk); | 963 | clk_put(dev->clk); |
975 | dev->clk = NULL; | 964 | dev->clk = NULL; |
976 | 965 | ||
977 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
978 | release_mem_region(mem->start, resource_size(mem)); | ||
979 | |||
980 | kfree(dev); | ||
981 | |||
982 | return 0; | 966 | return 0; |
983 | } | 967 | } |
984 | 968 | ||
@@ -991,17 +975,7 @@ static struct platform_driver davinci_mcasp_driver = { | |||
991 | }, | 975 | }, |
992 | }; | 976 | }; |
993 | 977 | ||
994 | static int __init davinci_mcasp_init(void) | 978 | module_platform_driver(davinci_mcasp_driver); |
995 | { | ||
996 | return platform_driver_register(&davinci_mcasp_driver); | ||
997 | } | ||
998 | module_init(davinci_mcasp_init); | ||
999 | |||
1000 | static void __exit davinci_mcasp_exit(void) | ||
1001 | { | ||
1002 | platform_driver_unregister(&davinci_mcasp_driver); | ||
1003 | } | ||
1004 | module_exit(davinci_mcasp_exit); | ||
1005 | 979 | ||
1006 | MODULE_AUTHOR("Steve Chen"); | 980 | MODULE_AUTHOR("Steve Chen"); |
1007 | MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface"); | 981 | MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface"); |