Commit 906a6e5a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

cpufreq: governor: Rework cpufreq_governor_dbs()

Since it is possible to obtain a pointer to struct dbs_governor
from a pointer to the struct governor embedded in it via
container_of(), the second argument of cpufreq_governor_init()
is not necessary.  Accordingly, cpufreq_governor_dbs() doesn't
need its second argument either and the ->governor callbacks
for both the ondemand and conservative governors may be set
to cpufreq_governor_dbs() directly.  Make that happen.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarSaravana Kannan <skannan@codeaurora.org>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 7bdad34d
...@@ -325,13 +325,10 @@ static void cs_exit(struct dbs_data *dbs_data, bool notify) ...@@ -325,13 +325,10 @@ static void cs_exit(struct dbs_data *dbs_data, bool notify)
define_get_cpu_dbs_routines(cs_cpu_dbs_info); define_get_cpu_dbs_routines(cs_cpu_dbs_info);
static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
unsigned int event);
static struct dbs_governor cs_dbs_gov = { static struct dbs_governor cs_dbs_gov = {
.gov = { .gov = {
.name = "conservative", .name = "conservative",
.governor = cs_cpufreq_governor_dbs, .governor = cpufreq_governor_dbs,
.max_transition_latency = TRANSITION_LATENCY_LIMIT, .max_transition_latency = TRANSITION_LATENCY_LIMIT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
...@@ -348,12 +345,6 @@ static struct dbs_governor cs_dbs_gov = { ...@@ -348,12 +345,6 @@ static struct dbs_governor cs_dbs_gov = {
#define CPU_FREQ_GOV_CONSERVATIVE (&cs_dbs_gov.gov) #define CPU_FREQ_GOV_CONSERVATIVE (&cs_dbs_gov.gov)
static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
unsigned int event)
{
return cpufreq_governor_dbs(policy, &cs_dbs_gov, event);
}
static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val, static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
void *data) void *data)
{ {
......
...@@ -328,9 +328,10 @@ static void free_common_dbs_info(struct cpufreq_policy *policy, ...@@ -328,9 +328,10 @@ static void free_common_dbs_info(struct cpufreq_policy *policy,
kfree(shared); kfree(shared);
} }
static int cpufreq_governor_init(struct cpufreq_policy *policy, static int cpufreq_governor_init(struct cpufreq_policy *policy)
struct dbs_governor *gov)
{ {
struct dbs_governor *gov = container_of(policy->governor,
struct dbs_governor, gov);
struct dbs_data *dbs_data = gov->gdbs_data; struct dbs_data *dbs_data = gov->gdbs_data;
unsigned int latency; unsigned int latency;
int ret; int ret;
...@@ -539,8 +540,7 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy) ...@@ -539,8 +540,7 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy)
return 0; return 0;
} }
int cpufreq_governor_dbs(struct cpufreq_policy *policy, int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event)
struct dbs_governor *gov, unsigned int event)
{ {
int ret = -EINVAL; int ret = -EINVAL;
...@@ -548,7 +548,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -548,7 +548,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
mutex_lock(&dbs_data_mutex); mutex_lock(&dbs_data_mutex);
if (event == CPUFREQ_GOV_POLICY_INIT) { if (event == CPUFREQ_GOV_POLICY_INIT) {
ret = cpufreq_governor_init(policy, gov); ret = cpufreq_governor_init(policy);
} else if (policy->governor_data) { } else if (policy->governor_data) {
switch (event) { switch (event) {
case CPUFREQ_GOV_POLICY_EXIT: case CPUFREQ_GOV_POLICY_EXIT:
......
...@@ -276,8 +276,7 @@ static ssize_t show_sampling_rate_min_gov_pol \ ...@@ -276,8 +276,7 @@ static ssize_t show_sampling_rate_min_gov_pol \
extern struct mutex dbs_data_mutex; extern struct mutex dbs_data_mutex;
extern struct mutex cpufreq_governor_lock; extern struct mutex cpufreq_governor_lock;
void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); void dbs_check_cpu(struct dbs_data *dbs_data, int cpu);
int cpufreq_governor_dbs(struct cpufreq_policy *policy, int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event);
struct dbs_governor *gov, unsigned int event);
void od_register_powersave_bias_handler(unsigned int (*f) void od_register_powersave_bias_handler(unsigned int (*f)
(struct cpufreq_policy *, unsigned int, unsigned int), (struct cpufreq_policy *, unsigned int, unsigned int),
unsigned int powersave_bias); unsigned int powersave_bias);
......
...@@ -539,13 +539,10 @@ static struct od_ops od_ops = { ...@@ -539,13 +539,10 @@ static struct od_ops od_ops = {
.freq_increase = dbs_freq_increase, .freq_increase = dbs_freq_increase,
}; };
static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy,
unsigned int event);
static struct dbs_governor od_dbs_gov = { static struct dbs_governor od_dbs_gov = {
.gov = { .gov = {
.name = "ondemand", .name = "ondemand",
.governor = od_cpufreq_governor_dbs, .governor = cpufreq_governor_dbs,
.max_transition_latency = TRANSITION_LATENCY_LIMIT, .max_transition_latency = TRANSITION_LATENCY_LIMIT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
...@@ -563,12 +560,6 @@ static struct dbs_governor od_dbs_gov = { ...@@ -563,12 +560,6 @@ static struct dbs_governor od_dbs_gov = {
#define CPU_FREQ_GOV_ONDEMAND (&od_dbs_gov.gov) #define CPU_FREQ_GOV_ONDEMAND (&od_dbs_gov.gov)
static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy,
unsigned int event)
{
return cpufreq_governor_dbs(policy, &od_dbs_gov, event);
}
static void od_set_powersave_bias(unsigned int powersave_bias) static void od_set_powersave_bias(unsigned int powersave_bias)
{ {
struct cpufreq_policy *policy; struct cpufreq_policy *policy;
......
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