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 <sboyd@codeaurora.org>
diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
index 0caa8d1..f968ffd9 100644
--- a/drivers/cpufreq/qcom-cpufreq.c
+++ b/drivers/cpufreq/qcom-cpufreq.c
@@ -364,7 +364,7 @@
 	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");
@@ -431,7 +431,15 @@
 		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[] = {
@@ -467,8 +475,7 @@
 		return rc;
 	}
 
-	register_pm_notifier(&msm_cpufreq_pm_notifier);
-	return cpufreq_register_driver(&msm_cpufreq_driver);
+	return 0;
 }
 
 subsys_initcall(msm_cpufreq_register);