From d9d6c80975835ef272d4c0c6ee997442df3b6cb0 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 22 Mar 2017 18:12:45 -0700 Subject: [PATCH] qcom-cpufreq: Register cpufreq driver in driver probe We don't handle probe defer very well in this driver. If the platform_driver_register() call doesn't immediately probe the driver there, or if that driver probe defers for some reason, then the cpufreq driver registration in msm_cpufreq_register() will fail due to a missing frequency table. Let's move the cpufreq driver registration (and platform suspend hook part) into the platform driver probe path, so we handle probe defer properly and avoid any issues with order of initializations. Change-Id: I14b514d46239f52b535563d49fb5c19d06072c3a Signed-off-by: Stephen Boyd Signed-off-by: Rohit Gupta Signed-off-by: Jonathan Avila --- drivers/cpufreq/qcom-cpufreq.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c index 7fce769b0fa7..412ab647b17b 100644 --- a/drivers/cpufreq/qcom-cpufreq.c +++ b/drivers/cpufreq/qcom-cpufreq.c @@ -343,7 +343,7 @@ static int msm_cpufreq_probe(struct platform_device *pdev) char clk_name[] = "cpu??_clk"; char tbl_name[] = "qcom,cpufreq-table-??"; struct clk *c; - int cpu; + int cpu, ret; struct cpufreq_frequency_table *ftbl; l2_clk = devm_clk_get(dev, "l2_clk"); @@ -410,7 +410,15 @@ static int msm_cpufreq_probe(struct platform_device *pdev) per_cpu(freq_table, cpu) = ftbl; } - return 0; + ret = register_pm_notifier(&msm_cpufreq_pm_notifier); + if (ret) + return ret; + + ret = cpufreq_register_driver(&msm_cpufreq_driver); + if (ret) + unregister_pm_notifier(&msm_cpufreq_pm_notifier); + + return ret; } static const struct of_device_id msm_cpufreq_match_table[] = { @@ -446,8 +454,7 @@ static int __init msm_cpufreq_register(void) return rc; } - register_pm_notifier(&msm_cpufreq_pm_notifier); - return cpufreq_register_driver(&msm_cpufreq_driver); + return 0; } subsys_initcall(msm_cpufreq_register);