From 3fc54d37ab64733448faf0185e19a80f070eb9e3 Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Fri, 13 Jan 2006 15:54:22 -0800 Subject: [CPUFREQ] Convert drivers/cpufreq semaphores to mutexes. 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 Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Dave Jones --- drivers/cpufreq/cpufreq_userspace.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'drivers/cpufreq/cpufreq_userspace.c') diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index d32bf3593cd3..4d6fa63da598 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -35,7 +36,7 @@ static unsigned int cpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace */ static unsigned int cpu_is_managed[NR_CPUS]; static struct cpufreq_policy current_policy[NR_CPUS]; -static DECLARE_MUTEX (userspace_sem); +static DEFINE_MUTEX (userspace_mutex); #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) @@ -70,7 +71,7 @@ static int cpufreq_set(unsigned int freq, unsigned int cpu) dprintk("cpufreq_set for cpu %u, freq %u kHz\n", cpu, freq); - down(&userspace_sem); + mutex_lock(&userspace_mutex); if (!cpu_is_managed[cpu]) goto err; @@ -83,16 +84,16 @@ static int cpufreq_set(unsigned int freq, unsigned int cpu) /* * We're safe from concurrent calls to ->target() here - * as we hold the userspace_sem lock. If we were calling + * as we hold the userspace_mutex lock. If we were calling * cpufreq_driver_target, a deadlock situation might occur: - * A: cpufreq_set (lock userspace_sem) -> cpufreq_driver_target(lock policy->lock) - * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> cpufreq_governor_userspace (lock userspace_sem) + * A: cpufreq_set (lock userspace_mutex) -> cpufreq_driver_target(lock policy->lock) + * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> cpufreq_governor_userspace (lock userspace_mutex) */ ret = __cpufreq_driver_target(¤t_policy[cpu], freq, CPUFREQ_RELATION_L); err: - up(&userspace_sem); + mutex_unlock(&userspace_mutex); return ret; } @@ -134,7 +135,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, if (!cpu_online(cpu)) return -EINVAL; BUG_ON(!policy->cur); - down(&userspace_sem); + mutex_lock(&userspace_mutex); cpu_is_managed[cpu] = 1; cpu_min_freq[cpu] = policy->min; cpu_max_freq[cpu] = policy->max; @@ -143,20 +144,20 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr); memcpy (¤t_policy[cpu], policy, sizeof(struct cpufreq_policy)); dprintk("managing cpu %u started (%u - %u kHz, currently %u kHz)\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu]); - up(&userspace_sem); + mutex_unlock(&userspace_mutex); break; case CPUFREQ_GOV_STOP: - down(&userspace_sem); + mutex_lock(&userspace_mutex); cpu_is_managed[cpu] = 0; cpu_min_freq[cpu] = 0; cpu_max_freq[cpu] = 0; cpu_set_freq[cpu] = 0; sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr); dprintk("managing cpu %u stopped\n", cpu); - up(&userspace_sem); + mutex_unlock(&userspace_mutex); break; case CPUFREQ_GOV_LIMITS: - down(&userspace_sem); + mutex_lock(&userspace_mutex); cpu_min_freq[cpu] = policy->min; cpu_max_freq[cpu] = policy->max; dprintk("limit event for cpu %u: %u - %u kHz, currently %u kHz, last set to %u kHz\n", cpu, cpu_min_freq[cpu], cpu_max_freq[cpu], cpu_cur_freq[cpu], cpu_set_freq[cpu]); @@ -171,7 +172,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, CPUFREQ_RELATION_L); } memcpy (¤t_policy[cpu], policy, sizeof(struct cpufreq_policy)); - up(&userspace_sem); + mutex_unlock(&userspace_mutex); break; } return 0; -- cgit v1.2.3