Commit a038895e authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki
Browse files

cpufreq: drivers with target_index() must set freq_table



Since the cpufreq core directly uses freq_table, for cpufreq drivers
that set their target_index() callback, make it mandatory for them to
set the same.

Since this is set per policy and normally from policy->init(), do this
from cpufreq_table_validate_and_sort() which gets called right after
->init().

Reported-by: default avatarYajun Deng <yajun.deng@linux.dev>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 175c9df1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -73,6 +73,11 @@ static inline bool has_target(void)
	return cpufreq_driver->target_index || cpufreq_driver->target;
}

bool has_target_index(void)
{
	return !!cpufreq_driver->target_index;
}

/* internal prototypes */
static unsigned int __cpufreq_get(struct cpufreq_policy *policy);
static int cpufreq_init_governor(struct cpufreq_policy *policy);
+6 −1
Original line number Diff line number Diff line
@@ -355,8 +355,13 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy)
{
	int ret;

	if (!policy->freq_table)
	if (!policy->freq_table) {
		/* Freq table must be passed by drivers with target_index() */
		if (has_target_index())
			return -EINVAL;

		return 0;
	}

	ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table);
	if (ret)
+1 −0
Original line number Diff line number Diff line
@@ -237,6 +237,7 @@ bool cpufreq_supports_freq_invariance(void);
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
void cpufreq_enable_fast_switch(struct cpufreq_policy *policy);
void cpufreq_disable_fast_switch(struct cpufreq_policy *policy);
bool has_target_index(void);
#else
static inline unsigned int cpufreq_get(unsigned int cpu)
{