diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-02-07 16:01:31 +0100 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-03-09 14:40:53 +0100 |
commit | 2bb8d94fb03f808022c620f54b602a1e26d5cbac (patch) | |
tree | 9b73be310729f138d4c47e3e51b707144c85aa21 /drivers/cpufreq/cpufreq_governor.c | |
parent | cpufreq: governor: Replace timers with utilization update callbacks (diff) | |
download | linux-2bb8d94fb03f808022c620f54b602a1e26d5cbac.tar.xz linux-2bb8d94fb03f808022c620f54b602a1e26d5cbac.zip |
cpufreq: governor: Use common mutex for dbs_data protection
Every governor relying on the common code in cpufreq_governor.c
has to provide its own mutex in struct common_dbs_data. However,
there actually is no need to have a separate mutex per governor
for this purpose, they may be using the same global mutex just
fine. Accordingly, introduce a single common mutex for that and
drop the mutex field from struct common_dbs_data.
That at least will ensure that the mutex is always present and
initialized regardless of what the particular governors do.
Another benefit is that the common code does not need a pointer to
a governor-related structure to get to the mutex which sometimes
helps.
Finally, it makes the code generally easier to follow.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Saravana Kannan <skannan@codeaurora.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/cpufreq/cpufreq_governor.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 6bc2f50cc1d9..f291fdd878ce 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -22,6 +22,9 @@ #include "cpufreq_governor.h" +DEFINE_MUTEX(dbs_data_mutex); +EXPORT_SYMBOL_GPL(dbs_data_mutex); + static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) { if (have_governor_per_policy()) @@ -543,7 +546,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, int ret; /* Lock governor to block concurrent initialization of governor */ - mutex_lock(&cdata->mutex); + mutex_lock(&dbs_data_mutex); if (have_governor_per_policy()) dbs_data = policy->governor_data; @@ -576,7 +579,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, } unlock: - mutex_unlock(&cdata->mutex); + mutex_unlock(&dbs_data_mutex); return ret; } |