Skip to content

Commit fddd8f8

Browse files
committed
cpufreq: Split cpufreq_offline()
Split the "core" part running under the policy rwsem out of cpufreq_offline() to allow the locking in cpufreq_remove_dev() to be rearranged more easily. As a side-effect this eliminates the unlock label that's not needed any more. 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 e1e962c commit fddd8f8

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,21 +1577,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
15771577
return 0;
15781578
}
15791579

1580-
static int cpufreq_offline(unsigned int cpu)
1580+
static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
15811581
{
1582-
struct cpufreq_policy *policy;
15831582
int ret;
15841583

1585-
pr_debug("%s: unregistering CPU %u\n", __func__, cpu);
1586-
1587-
policy = cpufreq_cpu_get_raw(cpu);
1588-
if (!policy) {
1589-
pr_debug("%s: No cpu_data found\n", __func__);
1590-
return 0;
1591-
}
1592-
1593-
down_write(&policy->rwsem);
1594-
15951584
if (has_target())
15961585
cpufreq_stop_governor(policy);
15971586

@@ -1609,7 +1598,7 @@ static int cpufreq_offline(unsigned int cpu)
16091598
pr_err("%s: Failed to start governor\n", __func__);
16101599
}
16111600

1612-
goto unlock;
1601+
return;
16131602
}
16141603

16151604
if (has_target())
@@ -1636,8 +1625,24 @@ static int cpufreq_offline(unsigned int cpu)
16361625
cpufreq_driver->exit(policy);
16371626
policy->freq_table = NULL;
16381627
}
1628+
}
1629+
1630+
static int cpufreq_offline(unsigned int cpu)
1631+
{
1632+
struct cpufreq_policy *policy;
1633+
1634+
pr_debug("%s: unregistering CPU %u\n", __func__, cpu);
1635+
1636+
policy = cpufreq_cpu_get_raw(cpu);
1637+
if (!policy) {
1638+
pr_debug("%s: No cpu_data found\n", __func__);
1639+
return 0;
1640+
}
1641+
1642+
down_write(&policy->rwsem);
1643+
1644+
__cpufreq_offline(cpu, policy);
16391645

1640-
unlock:
16411646
up_write(&policy->rwsem);
16421647
return 0;
16431648
}

0 commit comments

Comments
 (0)