diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2014-03-19 22:59:09 -0400 |
---|---|---|
committer | MyungJoo Ham <myungjoo.ham@samsung.com> | 2014-05-24 04:56:35 -0400 |
commit | 45c58e93c501425f73f43a2f572a516a226ebccd (patch) | |
tree | 5189a5bd46fc65aa41f275237057c15c60e86a7f | |
parent | 4b660a7f5c8099d88d1a43d8ae138965112592c7 (diff) |
PM / devfreq: exynos4: Fix bug of resource leak and code clean on probe()
This patch fix bug about resource leak when happening probe fail and code clean
to add debug message.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
-rw-r--r-- | drivers/devfreq/exynos/exynos4_bus.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/drivers/devfreq/exynos/exynos4_bus.c b/drivers/devfreq/exynos/exynos4_bus.c index e07b0c68c715..4c1bbd923c54 100644 --- a/drivers/devfreq/exynos/exynos4_bus.c +++ b/drivers/devfreq/exynos/exynos4_bus.c | |||
@@ -763,19 +763,11 @@ static int exynos4_bus_get_dev_status(struct device *dev, | |||
763 | return 0; | 763 | return 0; |
764 | } | 764 | } |
765 | 765 | ||
766 | static void exynos4_bus_exit(struct device *dev) | ||
767 | { | ||
768 | struct busfreq_data *data = dev_get_drvdata(dev); | ||
769 | |||
770 | devfreq_unregister_opp_notifier(dev, data->devfreq); | ||
771 | } | ||
772 | |||
773 | static struct devfreq_dev_profile exynos4_devfreq_profile = { | 766 | static struct devfreq_dev_profile exynos4_devfreq_profile = { |
774 | .initial_freq = 400000, | 767 | .initial_freq = 400000, |
775 | .polling_ms = 50, | 768 | .polling_ms = 50, |
776 | .target = exynos4_bus_target, | 769 | .target = exynos4_bus_target, |
777 | .get_dev_status = exynos4_bus_get_dev_status, | 770 | .get_dev_status = exynos4_bus_get_dev_status, |
778 | .exit = exynos4_bus_exit, | ||
779 | }; | 771 | }; |
780 | 772 | ||
781 | static int exynos4210_init_tables(struct busfreq_data *data) | 773 | static int exynos4210_init_tables(struct busfreq_data *data) |
@@ -1048,8 +1040,11 @@ static int exynos4_busfreq_probe(struct platform_device *pdev) | |||
1048 | dev_err(dev, "Cannot determine the device id %d\n", data->type); | 1040 | dev_err(dev, "Cannot determine the device id %d\n", data->type); |
1049 | err = -EINVAL; | 1041 | err = -EINVAL; |
1050 | } | 1042 | } |
1051 | if (err) | 1043 | if (err) { |
1044 | dev_err(dev, "Cannot initialize busfreq table %d\n", | ||
1045 | data->type); | ||
1052 | return err; | 1046 | return err; |
1047 | } | ||
1053 | 1048 | ||
1054 | data->vdd_int = devm_regulator_get(dev, "vdd_int"); | 1049 | data->vdd_int = devm_regulator_get(dev, "vdd_int"); |
1055 | if (IS_ERR(data->vdd_int)) { | 1050 | if (IS_ERR(data->vdd_int)) { |
@@ -1086,23 +1081,39 @@ static int exynos4_busfreq_probe(struct platform_device *pdev) | |||
1086 | if (IS_ERR(data->devfreq)) | 1081 | if (IS_ERR(data->devfreq)) |
1087 | return PTR_ERR(data->devfreq); | 1082 | return PTR_ERR(data->devfreq); |
1088 | 1083 | ||
1089 | devfreq_register_opp_notifier(dev, data->devfreq); | 1084 | /* Register opp_notifier for Exynos4 busfreq */ |
1085 | err = devfreq_register_opp_notifier(dev, data->devfreq); | ||
1086 | if (err < 0) { | ||
1087 | dev_err(dev, "Failed to register opp notifier\n"); | ||
1088 | goto err_notifier_opp; | ||
1089 | } | ||
1090 | 1090 | ||
1091 | /* Register pm_notifier for Exynos4 busfreq */ | ||
1091 | err = register_pm_notifier(&data->pm_notifier); | 1092 | err = register_pm_notifier(&data->pm_notifier); |
1092 | if (err) { | 1093 | if (err) { |
1093 | dev_err(dev, "Failed to setup pm notifier\n"); | 1094 | dev_err(dev, "Failed to setup pm notifier\n"); |
1094 | devfreq_remove_device(data->devfreq); | 1095 | goto err_notifier_pm; |
1095 | return err; | ||
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | return 0; | 1098 | return 0; |
1099 | |||
1100 | err_notifier_pm: | ||
1101 | devfreq_unregister_opp_notifier(dev, data->devfreq); | ||
1102 | err_notifier_opp: | ||
1103 | devfreq_remove_device(data->devfreq); | ||
1104 | |||
1105 | return err; | ||
1099 | } | 1106 | } |
1100 | 1107 | ||
1101 | static int exynos4_busfreq_remove(struct platform_device *pdev) | 1108 | static int exynos4_busfreq_remove(struct platform_device *pdev) |
1102 | { | 1109 | { |
1103 | struct busfreq_data *data = platform_get_drvdata(pdev); | 1110 | struct busfreq_data *data = platform_get_drvdata(pdev); |
1104 | 1111 | ||
1112 | /* Unregister all of notifier chain */ | ||
1105 | unregister_pm_notifier(&data->pm_notifier); | 1113 | unregister_pm_notifier(&data->pm_notifier); |
1114 | devfreq_unregister_opp_notifier(data->dev, data->devfreq); | ||
1115 | |||
1116 | /* Remove devfreq instance */ | ||
1106 | devfreq_remove_device(data->devfreq); | 1117 | devfreq_remove_device(data->devfreq); |
1107 | 1118 | ||
1108 | return 0; | 1119 | return 0; |