Skip to content

Commit e1e962c

Browse files
committed
cpufreq: Reorganize checks in cpufreq_offline()
Notice that cpufreq_offline() only needs to check policy_is_inactive() once and rearrange the code in there to make that happen. No expected functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 5c84c1b commit e1e962c

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,24 +1591,18 @@ static int cpufreq_offline(unsigned int cpu)
15911591
}
15921592

15931593
down_write(&policy->rwsem);
1594+
15941595
if (has_target())
15951596
cpufreq_stop_governor(policy);
15961597

15971598
cpumask_clear_cpu(cpu, policy->cpus);
15981599

1599-
if (policy_is_inactive(policy)) {
1600-
if (has_target())
1601-
strncpy(policy->last_governor, policy->governor->name,
1602-
CPUFREQ_NAME_LEN);
1603-
else
1604-
policy->last_policy = policy->policy;
1605-
} else if (cpu == policy->cpu) {
1606-
/* Nominate new CPU */
1607-
policy->cpu = cpumask_any(policy->cpus);
1608-
}
1609-
1610-
/* Start governor again for active policy */
16111600
if (!policy_is_inactive(policy)) {
1601+
/* Nominate a new CPU if necessary. */
1602+
if (cpu == policy->cpu)
1603+
policy->cpu = cpumask_any(policy->cpus);
1604+
1605+
/* Start the governor again for the active policy. */
16121606
if (has_target()) {
16131607
ret = cpufreq_start_governor(policy);
16141608
if (ret)
@@ -1618,6 +1612,12 @@ static int cpufreq_offline(unsigned int cpu)
16181612
goto unlock;
16191613
}
16201614

1615+
if (has_target())
1616+
strncpy(policy->last_governor, policy->governor->name,
1617+
CPUFREQ_NAME_LEN);
1618+
else
1619+
policy->last_policy = policy->policy;
1620+
16211621
if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
16221622
cpufreq_cooling_unregister(policy->cdev);
16231623
policy->cdev = NULL;

0 commit comments

Comments
 (0)