From c1b13d4e54d9777dc68c28503728ea63c6bfff37 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 9 May 2014 16:43:10 +0900 Subject: [PATCH] PM / devfreq: exynos4: Use devm_devfreq_* function using device resource management This patch uses devm_devfreq_add_device()/devm_devfreq_register_opp_notifier() to control automatically the resource of devfreq. Signed-off-by: Chanwoo Choi Cc: Kukjin Kim Cc: Bartlomiej Zolnierkiewicz Cc: Wei Yongjun Cc: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org Signed-off-by: MyungJoo Ham --- drivers/devfreq/exynos/exynos4_bus.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/devfreq/exynos/exynos4_bus.c b/drivers/devfreq/exynos/exynos4_bus.c index d257f1fcbaa9..bebb0a42b48e 100644 --- a/drivers/devfreq/exynos/exynos4_bus.c +++ b/drivers/devfreq/exynos/exynos4_bus.c @@ -979,7 +979,7 @@ static int exynos4_busfreq_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); - data->devfreq = devfreq_add_device(dev, &exynos4_devfreq_profile, + data->devfreq = devm_devfreq_add_device(dev, &exynos4_devfreq_profile, "simple_ondemand", NULL); if (IS_ERR(data->devfreq)) return PTR_ERR(data->devfreq); @@ -991,27 +991,20 @@ static int exynos4_busfreq_probe(struct platform_device *pdev) busfreq_mon_reset(ppmu_data); /* Register opp_notifier for Exynos4 busfreq */ - err = devfreq_register_opp_notifier(dev, data->devfreq); + err = devm_devfreq_register_opp_notifier(dev, data->devfreq); if (err < 0) { dev_err(dev, "Failed to register opp notifier\n"); - goto err_notifier_opp; + return err; } /* Register pm_notifier for Exynos4 busfreq */ err = register_pm_notifier(&data->pm_notifier); if (err) { dev_err(dev, "Failed to setup pm notifier\n"); - goto err_notifier_pm; + return err; } return 0; - -err_notifier_pm: - devfreq_unregister_opp_notifier(dev, data->devfreq); -err_notifier_opp: - devfreq_remove_device(data->devfreq); - - return err; } static int exynos4_busfreq_remove(struct platform_device *pdev) @@ -1020,10 +1013,6 @@ static int exynos4_busfreq_remove(struct platform_device *pdev) /* Unregister all of notifier chain */ unregister_pm_notifier(&data->pm_notifier); - devfreq_unregister_opp_notifier(data->dev, data->devfreq); - - /* Remove devfreq instance */ - devfreq_remove_device(data->devfreq); return 0; }