cpufreq: mvebu: Free opp if registering failed
authorGregory CLEMENT <gregory.clement@free-electrons.com>
Wed, 13 Dec 2017 17:29:14 +0000 (18:29 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 16 Dec 2017 01:29:43 +0000 (02:29 +0100)
Since the introduction of this driver, the functions to remove the opp
were added. So stop claiming we can't remove opp and use one of them in
case of failure.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/mvebu-cpufreq.c

index c043aad8e3a030d07e2eb57907bb138b6fe6fd5d..31513bd427054b71597696a1e62da4e31a6c5695 100644 (file)
@@ -76,12 +76,6 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
                        return PTR_ERR(clk);
                }
 
-               /*
-                * In case of a failure of dev_pm_opp_add(), we don't
-                * bother with cleaning up the registered OPP (there's
-                * no function to do so), and simply cancel the
-                * registration of the cpufreq device.
-                */
                ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0);
                if (ret) {
                        clk_put(clk);
@@ -91,7 +85,8 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
                ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0);
                if (ret) {
                        clk_put(clk);
-                       return ret;
+                       dev_err(cpu_dev, "Failed to register OPPs\n");
+                       goto opp_register_failed;
                }
 
                ret = dev_pm_opp_set_sharing_cpus(cpu_dev,
@@ -104,5 +99,11 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
 
        platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
        return 0;
+
+opp_register_failed:
+       /* As registering has failed remove all the opp for all cpus */
+       dev_pm_opp_cpumask_remove_table(cpu_possible_mask);
+
+       return ret;
 }
 device_initcall(armada_xp_pmsu_cpufreq_init);