[1/2] cpufreq: Reorder cpufreq_online() a bit
diff mbox

Message ID bd8c6133ad0bdd56c936802bcf26878d7cbdb679.1519279148.git.viresh.kumar@linaro.org
State Mainlined
Delegated to: Rafael Wysocki
Headers show

Commit Message

Viresh Kumar Feb. 22, 2018, 5:59 a.m. UTC
Ideally the de-allocation of resources should happen in the exact
opposite order in which they were allocated. It helps maintain the code
in long term, even if nothing really breaks with incorrect ordering.

The same wasn't followed in cpufreq_online() and it has some
inconsistencies. For example, the symlinks were created from within the
locked region while they are removed only after putting the locks. Also
->exit() should have been called only after the symlinks are removed and
the lock is dropped, as that was the case when ->init() was first

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
 drivers/cpufreq/cpufreq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff mbox

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index de33ebf008ad..8814c572e263 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1327,14 +1327,14 @@  static int cpufreq_online(unsigned int cpu)
 	return 0;
+	for_each_cpu(j, policy->real_cpus)
+		remove_cpu_dev_symlink(policy, get_cpu_device(j));
 	if (cpufreq_driver->exit)
-	for_each_cpu(j, policy->real_cpus)
-		remove_cpu_dev_symlink(policy, get_cpu_device(j));
 	return ret;