Commit d8d3b471 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

cpufreq: Pass policy to cpufreq_add_policy_cpu()

The caller of cpufreq_add_policy_cpu() already has a pointer to the
policy structure and there is no need to look it up again in
cpufreq_add_policy_cpu().  Let's pass it directly.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 10659ab7
...@@ -897,21 +897,17 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) ...@@ -897,21 +897,17 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy)
} }
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling, static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy,
struct device *dev, bool frozen) unsigned int cpu, struct device *dev,
bool frozen)
{ {
struct cpufreq_policy *policy;
int ret = 0, has_target = !!cpufreq_driver->target; int ret = 0, has_target = !!cpufreq_driver->target;
unsigned long flags; unsigned long flags;
policy = cpufreq_cpu_get(sibling);
if (WARN_ON_ONCE(!policy))
return -ENODATA;
if (has_target) if (has_target)
__cpufreq_governor(policy, CPUFREQ_GOV_STOP); __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
lock_policy_rwsem_write(sibling); lock_policy_rwsem_write(policy->cpu);
write_lock_irqsave(&cpufreq_driver_lock, flags); write_lock_irqsave(&cpufreq_driver_lock, flags);
...@@ -920,7 +916,7 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling, ...@@ -920,7 +916,7 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling,
per_cpu(cpufreq_cpu_data, cpu) = policy; per_cpu(cpufreq_cpu_data, cpu) = policy;
write_unlock_irqrestore(&cpufreq_driver_lock, flags); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
unlock_policy_rwsem_write(sibling); unlock_policy_rwsem_write(policy->cpu);
if (has_target) { if (has_target) {
__cpufreq_governor(policy, CPUFREQ_GOV_START); __cpufreq_governor(policy, CPUFREQ_GOV_START);
...@@ -931,7 +927,6 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling, ...@@ -931,7 +927,6 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling,
if (!frozen) if (!frozen)
ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq");
cpufreq_cpu_put(policy);
return ret; return ret;
} }
#endif #endif
...@@ -1014,8 +1009,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, ...@@ -1014,8 +1009,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling); struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling);
if (cp && cpumask_test_cpu(cpu, cp->related_cpus)) { if (cp && cpumask_test_cpu(cpu, cp->related_cpus)) {
read_unlock_irqrestore(&cpufreq_driver_lock, flags); read_unlock_irqrestore(&cpufreq_driver_lock, flags);
return cpufreq_add_policy_cpu(cpu, sibling, dev, return cpufreq_add_policy_cpu(cp, cpu, dev, frozen);
frozen);
} }
} }
read_unlock_irqrestore(&cpufreq_driver_lock, flags); read_unlock_irqrestore(&cpufreq_driver_lock, flags);
......
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