diff options
author | Amit Daniel Kachhap <amit.kachhap@linaro.org> | 2012-08-16 07:41:45 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2012-09-24 02:44:38 -0400 |
commit | 79e093c3fe9de9fe0743a53e4809f481d2719060 (patch) | |
tree | fb89193f5a6cbf2bad85c842d12b29f497121470 /drivers/thermal/exynos_thermal.c | |
parent | 17be868e04a1b98d72756ce7b51a95d03e7df49b (diff) |
thermal: exynos: Use devm_* functions
devm_* functions are used to replace kzalloc, request_mem_region, ioremap
and request_irq functions in probe call. With the usage of devm_* functions
explicit freeing and unmapping is not required.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Sachin Kamat <sachin.kamat@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/exynos_thermal.c')
-rw-r--r-- | drivers/thermal/exynos_thermal.c | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 03a99e444dbd..e84acde9e0bf 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c | |||
@@ -842,7 +842,8 @@ static int __devinit exynos_tmu_probe(struct platform_device *pdev) | |||
842 | dev_err(&pdev->dev, "No platform init data supplied.\n"); | 842 | dev_err(&pdev->dev, "No platform init data supplied.\n"); |
843 | return -ENODEV; | 843 | return -ENODEV; |
844 | } | 844 | } |
845 | data = kzalloc(sizeof(struct exynos_tmu_data), GFP_KERNEL); | 845 | data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data), |
846 | GFP_KERNEL); | ||
846 | if (!data) { | 847 | if (!data) { |
847 | dev_err(&pdev->dev, "Failed to allocate driver structure\n"); | 848 | dev_err(&pdev->dev, "Failed to allocate driver structure\n"); |
848 | return -ENOMEM; | 849 | return -ENOMEM; |
@@ -850,47 +851,35 @@ static int __devinit exynos_tmu_probe(struct platform_device *pdev) | |||
850 | 851 | ||
851 | data->irq = platform_get_irq(pdev, 0); | 852 | data->irq = platform_get_irq(pdev, 0); |
852 | if (data->irq < 0) { | 853 | if (data->irq < 0) { |
853 | ret = data->irq; | ||
854 | dev_err(&pdev->dev, "Failed to get platform irq\n"); | 854 | dev_err(&pdev->dev, "Failed to get platform irq\n"); |
855 | goto err_free; | 855 | return data->irq; |
856 | } | 856 | } |
857 | 857 | ||
858 | INIT_WORK(&data->irq_work, exynos_tmu_work); | 858 | INIT_WORK(&data->irq_work, exynos_tmu_work); |
859 | 859 | ||
860 | data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 860 | data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
861 | if (!data->mem) { | 861 | if (!data->mem) { |
862 | ret = -ENOENT; | ||
863 | dev_err(&pdev->dev, "Failed to get platform resource\n"); | 862 | dev_err(&pdev->dev, "Failed to get platform resource\n"); |
864 | goto err_free; | 863 | return -ENOENT; |
865 | } | 864 | } |
866 | 865 | ||
867 | data->mem = request_mem_region(data->mem->start, | 866 | data->base = devm_request_and_ioremap(&pdev->dev, data->mem); |
868 | resource_size(data->mem), pdev->name); | ||
869 | if (!data->mem) { | ||
870 | ret = -ENODEV; | ||
871 | dev_err(&pdev->dev, "Failed to request memory region\n"); | ||
872 | goto err_free; | ||
873 | } | ||
874 | |||
875 | data->base = ioremap(data->mem->start, resource_size(data->mem)); | ||
876 | if (!data->base) { | 867 | if (!data->base) { |
877 | ret = -ENODEV; | ||
878 | dev_err(&pdev->dev, "Failed to ioremap memory\n"); | 868 | dev_err(&pdev->dev, "Failed to ioremap memory\n"); |
879 | goto err_mem_region; | 869 | return -ENODEV; |
880 | } | 870 | } |
881 | 871 | ||
882 | ret = request_irq(data->irq, exynos_tmu_irq, | 872 | ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq, |
883 | IRQF_TRIGGER_RISING, "exynos-tmu", data); | 873 | IRQF_TRIGGER_RISING, "exynos-tmu", data); |
884 | if (ret) { | 874 | if (ret) { |
885 | dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq); | 875 | dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq); |
886 | goto err_io_remap; | 876 | return ret; |
887 | } | 877 | } |
888 | 878 | ||
889 | data->clk = clk_get(NULL, "tmu_apbif"); | 879 | data->clk = clk_get(NULL, "tmu_apbif"); |
890 | if (IS_ERR(data->clk)) { | 880 | if (IS_ERR(data->clk)) { |
891 | ret = PTR_ERR(data->clk); | ||
892 | dev_err(&pdev->dev, "Failed to get clock\n"); | 881 | dev_err(&pdev->dev, "Failed to get clock\n"); |
893 | goto err_irq; | 882 | return PTR_ERR(data->clk); |
894 | } | 883 | } |
895 | 884 | ||
896 | if (pdata->type == SOC_ARCH_EXYNOS || | 885 | if (pdata->type == SOC_ARCH_EXYNOS || |
@@ -942,15 +931,6 @@ static int __devinit exynos_tmu_probe(struct platform_device *pdev) | |||
942 | err_clk: | 931 | err_clk: |
943 | platform_set_drvdata(pdev, NULL); | 932 | platform_set_drvdata(pdev, NULL); |
944 | clk_put(data->clk); | 933 | clk_put(data->clk); |
945 | err_irq: | ||
946 | free_irq(data->irq, data); | ||
947 | err_io_remap: | ||
948 | iounmap(data->base); | ||
949 | err_mem_region: | ||
950 | release_mem_region(data->mem->start, resource_size(data->mem)); | ||
951 | err_free: | ||
952 | kfree(data); | ||
953 | |||
954 | return ret; | 934 | return ret; |
955 | } | 935 | } |
956 | 936 | ||
@@ -964,15 +944,8 @@ static int __devexit exynos_tmu_remove(struct platform_device *pdev) | |||
964 | 944 | ||
965 | clk_put(data->clk); | 945 | clk_put(data->clk); |
966 | 946 | ||
967 | free_irq(data->irq, data); | ||
968 | |||
969 | iounmap(data->base); | ||
970 | release_mem_region(data->mem->start, resource_size(data->mem)); | ||
971 | |||
972 | platform_set_drvdata(pdev, NULL); | 947 | platform_set_drvdata(pdev, NULL); |
973 | 948 | ||
974 | kfree(data); | ||
975 | |||
976 | return 0; | 949 | return 0; |
977 | } | 950 | } |
978 | 951 | ||