Skip to content

Commit

Permalink
cpufreq: Split cpufreq_offline()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafael J. Wysocki committed May 12, 2022
1 parent e1e962c commit fddd8f8
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,21 +1577,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
return 0;
}

static int cpufreq_offline(unsigned int cpu)
static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
{
struct cpufreq_policy *policy;
int ret;

pr_debug("%s: unregistering CPU %u\n", __func__, cpu);

policy = cpufreq_cpu_get_raw(cpu);
if (!policy) {
pr_debug("%s: No cpu_data found\n", __func__);
return 0;
}

down_write(&policy->rwsem);

if (has_target())
cpufreq_stop_governor(policy);

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

goto unlock;
return;
}

if (has_target())
Expand All @@ -1636,8 +1625,24 @@ static int cpufreq_offline(unsigned int cpu)
cpufreq_driver->exit(policy);
policy->freq_table = NULL;
}
}

static int cpufreq_offline(unsigned int cpu)
{
struct cpufreq_policy *policy;

pr_debug("%s: unregistering CPU %u\n", __func__, cpu);

policy = cpufreq_cpu_get_raw(cpu);
if (!policy) {
pr_debug("%s: No cpu_data found\n", __func__);
return 0;
}

down_write(&policy->rwsem);

__cpufreq_offline(cpu, policy);

unlock:
up_write(&policy->rwsem);
return 0;
}
Expand Down

0 comments on commit fddd8f8

Please sign in to comment.