Skip to content

Commit 4221504

Browse files
Lifeng Zhengwilldeacon
authored andcommitted
cpufreq: Add new helper function returning cpufreq policy
cpufreq_cpu_get_raw() gets cpufreq policy only if the CPU is in policy->cpus mask, which means the CPU is already online. But in some cases, the policy is needed before the CPU is added to cpus mask. Add a function to get the policy in these cases. Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com> Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Reviewed-by: Jie Zhan <zhanjie9@hisilicon.com> Acked-by: Beata Michalska <beata.michalska@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent af15bc2 commit 4221504

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
198198
}
199199
EXPORT_SYMBOL_GPL(cpufreq_cpu_get_raw);
200200

201+
struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu)
202+
{
203+
return per_cpu(cpufreq_cpu_data, cpu);
204+
}
205+
EXPORT_SYMBOL_GPL(cpufreq_cpu_policy);
206+
201207
unsigned int cpufreq_generic_get(unsigned int cpu)
202208
{
203209
struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);

include/linux/cpufreq.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,18 @@ struct cpufreq_freqs {
203203

204204
#ifdef CONFIG_CPU_FREQ
205205
struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
206+
struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu);
206207
struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
207208
void cpufreq_cpu_put(struct cpufreq_policy *policy);
208209
#else
209210
static inline struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
210211
{
211212
return NULL;
212213
}
214+
static inline struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu)
215+
{
216+
return NULL;
217+
}
213218
static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
214219
{
215220
return NULL;

0 commit comments

Comments
 (0)