Change cpufreq_policy_alloc() to take a CPU number instead of a CPU
device pointer as its argument, as it is the only function called by
cpufreq_add_dev() taking a device pointer argument at this point.
That will allow us to split the CPU online part from cpufreq_add_dev()
more cleanly going forward.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
-static struct cpufreq_policy *cpufreq_policy_alloc(struct device *dev)
+static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
+ struct device *dev = get_cpu_device(cpu);
struct cpufreq_policy *policy;
int ret;
struct cpufreq_policy *policy;
int ret;
+ if (WARN_ON(!dev))
+ return NULL;
+
policy = kzalloc(sizeof(*policy), GFP_KERNEL);
if (!policy)
return NULL;
policy = kzalloc(sizeof(*policy), GFP_KERNEL);
if (!policy)
return NULL;
init_completion(&policy->kobj_unregister);
INIT_WORK(&policy->update, handle_update);
init_completion(&policy->kobj_unregister);
INIT_WORK(&policy->update, handle_update);
/* Set this once on allocation */
/* Set this once on allocation */
- policy->kobj_cpu = dev->id;
+ policy->kobj_cpu = cpu;
up_write(&policy->rwsem);
} else {
recover_policy = false;
up_write(&policy->rwsem);
} else {
recover_policy = false;
- policy = cpufreq_policy_alloc(dev);
+ policy = cpufreq_policy_alloc(cpu);
if (!policy)
return -ENOMEM;
}
if (!policy)
return -ENOMEM;
}