aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2012-08-21 06:05:32 -0400
committerMyungJoo Ham <myungjoo.ham@samsung.com>2012-11-20 01:59:22 -0500
commitd7895052d97cde63b34e5185da28052384fa8564 (patch)
tree0ef586215499c37397942d66c2ccc77c374a54fc
parent1a1357ea176670867f347419c3345e2becc07338 (diff)
PM / devfreq: Use devm_* functions in exynos4_bus.c
devm_* functions are device managed functions and make cleanup code simpler and smaller. devm_kzalloc and devm_regulator_get functions are used. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> [renamed the patch title by MyungJoo Ham] Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
-rw-r--r--drivers/devfreq/exynos4_bus.c41
1 files changed, 11 insertions, 30 deletions
diff --git a/drivers/devfreq/exynos4_bus.c b/drivers/devfreq/exynos4_bus.c
index 88ddc77a9bb1..68145316c49c 100644
--- a/drivers/devfreq/exynos4_bus.c
+++ b/drivers/devfreq/exynos4_bus.c
@@ -987,7 +987,7 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev)
987 struct device *dev = &pdev->dev; 987 struct device *dev = &pdev->dev;
988 int err = 0; 988 int err = 0;
989 989
990 data = kzalloc(sizeof(struct busfreq_data), GFP_KERNEL); 990 data = devm_kzalloc(&pdev->dev, sizeof(struct busfreq_data), GFP_KERNEL);
991 if (data == NULL) { 991 if (data == NULL) {
992 dev_err(dev, "Cannot allocate memory.\n"); 992 dev_err(dev, "Cannot allocate memory.\n");
993 return -ENOMEM; 993 return -ENOMEM;
@@ -1012,22 +1012,18 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev)
1012 err = -EINVAL; 1012 err = -EINVAL;
1013 } 1013 }
1014 if (err) 1014 if (err)
1015 goto err_regulator; 1015 return err;
1016 1016
1017 data->vdd_int = regulator_get(dev, "vdd_int"); 1017 data->vdd_int = devm_regulator_get(dev, "vdd_int");
1018 if (IS_ERR(data->vdd_int)) { 1018 if (IS_ERR(data->vdd_int)) {
1019 dev_err(dev, "Cannot get the regulator \"vdd_int\"\n"); 1019 dev_err(dev, "Cannot get the regulator \"vdd_int\"\n");
1020 err = PTR_ERR(data->vdd_int); 1020 return PTR_ERR(data->vdd_int);
1021 goto err_regulator;
1022 } 1021 }
1023 if (data->type == TYPE_BUSF_EXYNOS4x12) { 1022 if (data->type == TYPE_BUSF_EXYNOS4x12) {
1024 data->vdd_mif = regulator_get(dev, "vdd_mif"); 1023 data->vdd_mif = devm_regulator_get(dev, "vdd_mif");
1025 if (IS_ERR(data->vdd_mif)) { 1024 if (IS_ERR(data->vdd_mif)) {
1026 dev_err(dev, "Cannot get the regulator \"vdd_mif\"\n"); 1025 dev_err(dev, "Cannot get the regulator \"vdd_mif\"\n");
1027 err = PTR_ERR(data->vdd_mif); 1026 return PTR_ERR(data->vdd_mif);
1028 regulator_put(data->vdd_int);
1029 goto err_regulator;
1030
1031 } 1027 }
1032 } 1028 }
1033 1029
@@ -1035,8 +1031,7 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev)
1035 if (IS_ERR(opp)) { 1031 if (IS_ERR(opp)) {
1036 dev_err(dev, "Invalid initial frequency %lu kHz.\n", 1032 dev_err(dev, "Invalid initial frequency %lu kHz.\n",
1037 exynos4_devfreq_profile.initial_freq); 1033 exynos4_devfreq_profile.initial_freq);
1038 err = PTR_ERR(opp); 1034 return PTR_ERR(opp);
1039 goto err_opp_add;
1040 } 1035 }
1041 data->curr_opp = opp; 1036 data->curr_opp = opp;
1042 1037
@@ -1046,29 +1041,19 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev)
1046 1041
1047 data->devfreq = devfreq_add_device(dev, &exynos4_devfreq_profile, 1042 data->devfreq = devfreq_add_device(dev, &exynos4_devfreq_profile,
1048 &devfreq_simple_ondemand, NULL); 1043 &devfreq_simple_ondemand, NULL);
1049 if (IS_ERR(data->devfreq)) { 1044 if (IS_ERR(data->devfreq))
1050 err = PTR_ERR(data->devfreq); 1045 return PTR_ERR(data->devfreq);
1051 goto err_opp_add;
1052 }
1053 1046
1054 devfreq_register_opp_notifier(dev, data->devfreq); 1047 devfreq_register_opp_notifier(dev, data->devfreq);
1055 1048
1056 err = register_pm_notifier(&data->pm_notifier); 1049 err = register_pm_notifier(&data->pm_notifier);
1057 if (err) { 1050 if (err) {
1058 dev_err(dev, "Failed to setup pm notifier\n"); 1051 dev_err(dev, "Failed to setup pm notifier\n");
1059 goto err_devfreq_add; 1052 devfreq_remove_device(data->devfreq);
1053 return err;
1060 } 1054 }
1061 1055
1062 return 0; 1056 return 0;
1063err_devfreq_add:
1064 devfreq_remove_device(data->devfreq);
1065err_opp_add:
1066 if (data->vdd_mif)
1067 regulator_put(data->vdd_mif);
1068 regulator_put(data->vdd_int);
1069err_regulator:
1070 kfree(data);
1071 return err;
1072} 1057}
1073 1058
1074static __devexit int exynos4_busfreq_remove(struct platform_device *pdev) 1059static __devexit int exynos4_busfreq_remove(struct platform_device *pdev)
@@ -1077,10 +1062,6 @@ static __devexit int exynos4_busfreq_remove(struct platform_device *pdev)
1077 1062
1078 unregister_pm_notifier(&data->pm_notifier); 1063 unregister_pm_notifier(&data->pm_notifier);
1079 devfreq_remove_device(data->devfreq); 1064 devfreq_remove_device(data->devfreq);
1080 regulator_put(data->vdd_int);
1081 if (data->vdd_mif)
1082 regulator_put(data->vdd_mif);
1083 kfree(data);
1084 1065
1085 return 0; 1066 return 0;
1086} 1067}