Commit b1593e53 authored by Viresh Kumar's avatar Viresh Kumar

Merge commit 'ded10c47' into HEAD

parents dc279ac6 ded10c47
...@@ -48,7 +48,6 @@ static struct clk_bulk_data clks[] = { ...@@ -48,7 +48,6 @@ static struct clk_bulk_data clks[] = {
}; };
static struct device *cpu_dev; static struct device *cpu_dev;
static bool free_opp;
static struct cpufreq_frequency_table *freq_table; static struct cpufreq_frequency_table *freq_table;
static unsigned int max_freq; static unsigned int max_freq;
static unsigned int transition_latency; static unsigned int transition_latency;
...@@ -390,9 +389,6 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ...@@ -390,9 +389,6 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
goto put_reg; goto put_reg;
} }
/* Because we have added the OPPs here, we must free them */
free_opp = true;
if (of_machine_is_compatible("fsl,imx6ul") || if (of_machine_is_compatible("fsl,imx6ul") ||
of_machine_is_compatible("fsl,imx6ull")) { of_machine_is_compatible("fsl,imx6ull")) {
ret = imx6ul_opp_check_speed_grading(cpu_dev); ret = imx6ul_opp_check_speed_grading(cpu_dev);
...@@ -507,8 +503,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ...@@ -507,8 +503,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
free_freq_table: free_freq_table:
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
out_free_opp: out_free_opp:
if (free_opp) dev_pm_opp_of_remove_table(cpu_dev);
dev_pm_opp_of_remove_table(cpu_dev);
put_reg: put_reg:
if (!IS_ERR(arm_reg)) if (!IS_ERR(arm_reg))
regulator_put(arm_reg); regulator_put(arm_reg);
...@@ -528,8 +523,7 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev) ...@@ -528,8 +523,7 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev)
{ {
cpufreq_unregister_driver(&imx6q_cpufreq_driver); cpufreq_unregister_driver(&imx6q_cpufreq_driver);
dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
if (free_opp) dev_pm_opp_of_remove_table(cpu_dev);
dev_pm_opp_of_remove_table(cpu_dev);
regulator_put(arm_reg); regulator_put(arm_reg);
if (!IS_ERR(pu_reg)) if (!IS_ERR(pu_reg))
regulator_put(pu_reg); regulator_put(pu_reg);
......
...@@ -1300,13 +1300,19 @@ void dev_pm_opp_remove(struct device *dev, unsigned long freq) ...@@ -1300,13 +1300,19 @@ void dev_pm_opp_remove(struct device *dev, unsigned long freq)
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_remove); EXPORT_SYMBOL_GPL(dev_pm_opp_remove);
void _opp_remove_all_static(struct opp_table *opp_table) bool _opp_remove_all_static(struct opp_table *opp_table)
{ {
struct dev_pm_opp *opp, *tmp; struct dev_pm_opp *opp, *tmp;
bool ret = true;
mutex_lock(&opp_table->lock); mutex_lock(&opp_table->lock);
if (!opp_table->parsed_static_opps || --opp_table->parsed_static_opps) if (!opp_table->parsed_static_opps) {
ret = false;
goto unlock;
}
if (--opp_table->parsed_static_opps)
goto unlock; goto unlock;
list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) { list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
...@@ -1316,6 +1322,8 @@ void _opp_remove_all_static(struct opp_table *opp_table) ...@@ -1316,6 +1322,8 @@ void _opp_remove_all_static(struct opp_table *opp_table)
unlock: unlock:
mutex_unlock(&opp_table->lock); mutex_unlock(&opp_table->lock);
return ret;
} }
/** /**
...@@ -2418,13 +2426,15 @@ void _dev_pm_opp_find_and_remove_table(struct device *dev) ...@@ -2418,13 +2426,15 @@ void _dev_pm_opp_find_and_remove_table(struct device *dev)
return; return;
} }
_opp_remove_all_static(opp_table); /*
* Drop the extra reference only if the OPP table was successfully added
* with dev_pm_opp_of_add_table() earlier.
**/
if (_opp_remove_all_static(opp_table))
dev_pm_opp_put_opp_table(opp_table);
/* Drop reference taken by _find_opp_table() */ /* Drop reference taken by _find_opp_table() */
dev_pm_opp_put_opp_table(opp_table); dev_pm_opp_put_opp_table(opp_table);
/* Drop reference taken while the OPP table was added */
dev_pm_opp_put_opp_table(opp_table);
} }
/** /**
......
...@@ -212,7 +212,7 @@ struct opp_table { ...@@ -212,7 +212,7 @@ struct opp_table {
/* Routines internal to opp core */ /* Routines internal to opp core */
void dev_pm_opp_get(struct dev_pm_opp *opp); void dev_pm_opp_get(struct dev_pm_opp *opp);
void _opp_remove_all_static(struct opp_table *opp_table); bool _opp_remove_all_static(struct opp_table *opp_table);
void _get_opp_table_kref(struct opp_table *opp_table); void _get_opp_table_kref(struct opp_table *opp_table);
int _get_opp_count(struct opp_table *opp_table); int _get_opp_count(struct opp_table *opp_table);
struct opp_table *_find_opp_table(struct device *dev); struct opp_table *_find_opp_table(struct device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment