aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_userspace.c
diff options
context:
space:
mode:
authorakpm@osdl.org <akpm@osdl.org>2006-01-13 18:54:22 -0500
committerDave Jones <davej@redhat.com>2006-01-18 16:53:45 -0500
commit3fc54d37ab64733448faf0185e19a80f070eb9e3 (patch)
tree58f373f0e519007795fe58d8663b53bab4cb4feb /drivers/cpufreq/cpufreq_userspace.c
parent7eb9b2f56c9812d03ac63031869bcc42151067b1 (diff)
[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 <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>
Diffstat (limited to 'drivers/cpufreq/cpufreq_userspace.c')
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c25
1 files changed, 13 insertions, 12 deletions
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 @@
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/sysfs.h> 23#include <linux/sysfs.h>
24#include <linux/mutex.h>
24 25
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26 27
@@ -35,7 +36,7 @@ static unsigned int cpu_set_freq[NR_CPUS]; /* CPU freq desired by userspace */
35static unsigned int cpu_is_managed[NR_CPUS]; 36static unsigned int cpu_is_managed[NR_CPUS];
36static struct cpufreq_policy current_policy[NR_CPUS]; 37static struct cpufreq_policy current_policy[NR_CPUS];
37 38
38static DECLARE_MUTEX (userspace_sem); 39static DEFINE_MUTEX (userspace_mutex);
39 40
40#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg) 41#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_GOVERNOR, "userspace", msg)
41 42
@@ -70,7 +71,7 @@ static int cpufreq_set(unsigned int freq, unsigned int cpu)
70 71
71 dprintk("cpufreq_set for cpu %u, freq %u kHz\n", cpu, freq); 72 dprintk("cpufreq_set for cpu %u, freq %u kHz\n", cpu, freq);
72 73
73 down(&userspace_sem); 74 mutex_lock(&userspace_mutex);
74 if (!cpu_is_managed[cpu]) 75 if (!cpu_is_managed[cpu])
75 goto err; 76 goto err;
76 77
@@ -83,16 +84,16 @@ static int cpufreq_set(unsigned int freq, unsigned int cpu)
83 84
84 /* 85 /*
85 * We're safe from concurrent calls to ->target() here 86 * We're safe from concurrent calls to ->target() here
86 * as we hold the userspace_sem lock. If we were calling 87 * as we hold the userspace_mutex lock. If we were calling
87 * cpufreq_driver_target, a deadlock situation might occur: 88 * cpufreq_driver_target, a deadlock situation might occur:
88 * A: cpufreq_set (lock userspace_sem) -> cpufreq_driver_target(lock policy->lock) 89 * A: cpufreq_set (lock userspace_mutex) -> cpufreq_driver_target(lock policy->lock)
89 * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> cpufreq_governor_userspace (lock userspace_sem) 90 * B: cpufreq_set_policy(lock policy->lock) -> __cpufreq_governor -> cpufreq_governor_userspace (lock userspace_mutex)
90 */ 91 */
91 ret = __cpufreq_driver_target(&current_policy[cpu], freq, 92 ret = __cpufreq_driver_target(&current_policy[cpu], freq,
92 CPUFREQ_RELATION_L); 93 CPUFREQ_RELATION_L);
93 94
94 err: 95 err:
95 up(&userspace_sem); 96 mutex_unlock(&userspace_mutex);
96 return ret; 97 return ret;
97} 98}
98 99
@@ -134,7 +135,7 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
134 if (!cpu_online(cpu)) 135 if (!cpu_online(cpu))
135 return -EINVAL; 136 return -EINVAL;
136 BUG_ON(!policy->cur); 137 BUG_ON(!policy->cur);
137 down(&userspace_sem); 138 mutex_lock(&userspace_mutex);
138 cpu_is_managed[cpu] = 1; 139 cpu_is_managed[cpu] = 1;
139 cpu_min_freq[cpu] = policy->min; 140 cpu_min_freq[cpu] = policy->min;
140 cpu_max_freq[cpu] = policy->max; 141 cpu_max_freq[cpu] = policy->max;
@@ -143,20 +144,20 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
143 sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr); 144 sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
144 memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy)); 145 memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy));
145 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]); 146 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]);
146 up(&userspace_sem); 147 mutex_unlock(&userspace_mutex);
147 break; 148 break;
148 case CPUFREQ_GOV_STOP: 149 case CPUFREQ_GOV_STOP:
149 down(&userspace_sem); 150 mutex_lock(&userspace_mutex);
150 cpu_is_managed[cpu] = 0; 151 cpu_is_managed[cpu] = 0;
151 cpu_min_freq[cpu] = 0; 152 cpu_min_freq[cpu] = 0;
152 cpu_max_freq[cpu] = 0; 153 cpu_max_freq[cpu] = 0;
153 cpu_set_freq[cpu] = 0; 154 cpu_set_freq[cpu] = 0;
154 sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr); 155 sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
155 dprintk("managing cpu %u stopped\n", cpu); 156 dprintk("managing cpu %u stopped\n", cpu);
156 up(&userspace_sem); 157 mutex_unlock(&userspace_mutex);
157 break; 158 break;
158 case CPUFREQ_GOV_LIMITS: 159 case CPUFREQ_GOV_LIMITS:
159 down(&userspace_sem); 160 mutex_lock(&userspace_mutex);
160 cpu_min_freq[cpu] = policy->min; 161 cpu_min_freq[cpu] = policy->min;
161 cpu_max_freq[cpu] = policy->max; 162 cpu_max_freq[cpu] = policy->max;
162 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]); 163 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,
171 CPUFREQ_RELATION_L); 172 CPUFREQ_RELATION_L);
172 } 173 }
173 memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy)); 174 memcpy (&current_policy[cpu], policy, sizeof(struct cpufreq_policy));
174 up(&userspace_sem); 175 mutex_unlock(&userspace_mutex);
175 break; 176 break;
176 } 177 }
177 return 0; 178 return 0;