Skip to content

Commit

Permalink
[CPUFREQ] Convert drivers/cpufreq semaphores to mutexes.
Browse files Browse the repository at this point in the history
Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dave Jones <davej@redhat.com>
  • Loading branch information
akpm@osdl.org authored and Dave Jones committed Jan 18, 2006
1 parent 7eb9b2f commit 3fc54d3
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 67 deletions.
19 changes: 10 additions & 9 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/cpu.h>
#include <linux/completion.h>
#include <linux/mutex.h>

#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, "cpufreq-core", msg)

Expand Down Expand Up @@ -55,7 +56,7 @@ static DECLARE_RWSEM (cpufreq_notifier_rwsem);


static LIST_HEAD(cpufreq_governor_list);
static DECLARE_MUTEX (cpufreq_governor_sem);
static DEFINE_MUTEX (cpufreq_governor_mutex);

struct cpufreq_policy * cpufreq_cpu_get(unsigned int cpu)
{
Expand Down Expand Up @@ -297,18 +298,18 @@ static int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
return -EINVAL;
} else {
struct cpufreq_governor *t;
down(&cpufreq_governor_sem);
mutex_lock(&cpufreq_governor_mutex);
if (!cpufreq_driver || !cpufreq_driver->target)
goto out;
list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN)) {
*governor = t;
up(&cpufreq_governor_sem);
mutex_unlock(&cpufreq_governor_mutex);
return 0;
}
}
out:
up(&cpufreq_governor_sem);
mutex_unlock(&cpufreq_governor_mutex);
}
return -EINVAL;
}
Expand Down Expand Up @@ -1217,17 +1218,17 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
if (!governor)
return -EINVAL;

down(&cpufreq_governor_sem);
mutex_lock(&cpufreq_governor_mutex);

list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) {
up(&cpufreq_governor_sem);
mutex_unlock(&cpufreq_governor_mutex);
return -EBUSY;
}
}
list_add(&governor->governor_list, &cpufreq_governor_list);

up(&cpufreq_governor_sem);
mutex_unlock(&cpufreq_governor_mutex);

return 0;
}
Expand All @@ -1239,9 +1240,9 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
if (!governor)
return;

down(&cpufreq_governor_sem);
mutex_lock(&cpufreq_governor_mutex);
list_del(&governor->governor_list);
up(&cpufreq_governor_sem);
mutex_unlock(&cpufreq_governor_mutex);
return;
}
EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
Expand Down
52 changes: 26 additions & 26 deletions drivers/cpufreq/cpufreq_conservative.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <linux/jiffies.h>
#include <linux/kernel_stat.h>
#include <linux/percpu.h>

#include <linux/mutex.h>
/*
* dbs is used in this file as a shortform for demandbased switching
* It helps to keep variable names smaller, simpler
Expand Down Expand Up @@ -71,7 +71,7 @@ static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);

static unsigned int dbs_enable; /* number of CPUs using this policy */

static DECLARE_MUTEX (dbs_sem);
static DEFINE_MUTEX (dbs_mutex);
static DECLARE_WORK (dbs_work, do_dbs_timer, NULL);

struct dbs_tuners {
Expand Down Expand Up @@ -139,9 +139,9 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
if (ret != 1 )
return -EINVAL;

down(&dbs_sem);
mutex_lock(&dbs_mutex);
dbs_tuners_ins.sampling_down_factor = input;
up(&dbs_sem);
mutex_unlock(&dbs_mutex);

return count;
}
Expand All @@ -153,14 +153,14 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
int ret;
ret = sscanf (buf, "%u", &input);

down(&dbs_sem);
mutex_lock(&dbs_mutex);
if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) {
up(&dbs_sem);
mutex_unlock(&dbs_mutex);
return -EINVAL;
}

dbs_tuners_ins.sampling_rate = input;
up(&dbs_sem);
mutex_unlock(&dbs_mutex);

return count;
}
Expand All @@ -172,16 +172,16 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
int ret;
ret = sscanf (buf, "%u", &input);

down(&dbs_sem);
mutex_lock(&dbs_mutex);
if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
input < MIN_FREQUENCY_UP_THRESHOLD ||
input <= dbs_tuners_ins.down_threshold) {
up(&dbs_sem);
mutex_unlock(&dbs_mutex);
return -EINVAL;
}

dbs_tuners_ins.up_threshold = input;
up(&dbs_sem);
mutex_unlock(&dbs_mutex);

return count;
}
Expand All @@ -193,16 +193,16 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused,
int ret;
ret = sscanf (buf, "%u", &input);

down(&dbs_sem);
mutex_lock(&dbs_mutex);
if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD ||
input < MIN_FREQUENCY_DOWN_THRESHOLD ||
input >= dbs_tuners_ins.up_threshold) {
up(&dbs_sem);
mutex_unlock(&dbs_mutex);
return -EINVAL;
}

dbs_tuners_ins.down_threshold = input;
up(&dbs_sem);
mutex_unlock(&dbs_mutex);

return count;
}
Expand All @@ -222,9 +222,9 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
if ( input > 1 )
input = 1;

down(&dbs_sem);
mutex_lock(&dbs_mutex);
if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */
up(&dbs_sem);
mutex_unlock(&dbs_mutex);
return count;
}
dbs_tuners_ins.ignore_nice = input;
Expand All @@ -236,7 +236,7 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j);
j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up;
}
up(&dbs_sem);
mutex_unlock(&dbs_mutex);

return count;
}
Expand All @@ -257,9 +257,9 @@ static ssize_t store_freq_step(struct cpufreq_policy *policy,

/* no need to test here if freq_step is zero as the user might actually
* want this, they would be crazy though :) */
down(&dbs_sem);
mutex_lock(&dbs_mutex);
dbs_tuners_ins.freq_step = input;
up(&dbs_sem);
mutex_unlock(&dbs_mutex);

return count;
}
Expand Down Expand Up @@ -444,12 +444,12 @@ static void dbs_check_cpu(int cpu)
static void do_dbs_timer(void *data)
{
int i;
down(&dbs_sem);
mutex_lock(&dbs_mutex);
for_each_online_cpu(i)
dbs_check_cpu(i);
schedule_delayed_work(&dbs_work,
usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
up(&dbs_sem);
mutex_unlock(&dbs_mutex);
}

static inline void dbs_timer_init(void)
Expand Down Expand Up @@ -487,7 +487,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
if (this_dbs_info->enable) /* Already enabled */
break;

down(&dbs_sem);
mutex_lock(&dbs_mutex);
for_each_cpu_mask(j, policy->cpus) {
struct cpu_dbs_info_s *j_dbs_info;
j_dbs_info = &per_cpu(cpu_dbs_info, j);
Expand Down Expand Up @@ -521,11 +521,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
dbs_timer_init();
}

up(&dbs_sem);
mutex_unlock(&dbs_mutex);
break;

case CPUFREQ_GOV_STOP:
down(&dbs_sem);
mutex_lock(&dbs_mutex);
this_dbs_info->enable = 0;
sysfs_remove_group(&policy->kobj, &dbs_attr_group);
dbs_enable--;
Expand All @@ -536,12 +536,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
if (dbs_enable == 0)
dbs_timer_exit();

up(&dbs_sem);
mutex_unlock(&dbs_mutex);

break;

case CPUFREQ_GOV_LIMITS:
down(&dbs_sem);
mutex_lock(&dbs_mutex);
if (policy->max < this_dbs_info->cur_policy->cur)
__cpufreq_driver_target(
this_dbs_info->cur_policy,
Expand All @@ -550,7 +550,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
__cpufreq_driver_target(
this_dbs_info->cur_policy,
policy->min, CPUFREQ_RELATION_L);
up(&dbs_sem);
mutex_unlock(&dbs_mutex);
break;
}
return 0;
Expand Down
Loading

0 comments on commit 3fc54d3

Please sign in to comment.