aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2011-03-27 09:04:46 -0400
committerDave Jones <davej@redhat.com>2011-05-04 11:50:57 -0400
commit2d06d8c49afdcc9bb35a85039fa50f0fe35bd40e (patch)
treed933a68fc71f6e2c3b95b744a87fa1d817bea3d6 /drivers/cpufreq/cpufreq.c
parent27ecddc2a9f99ce4ac9a59a0acd77f7100b6d034 (diff)
[CPUFREQ] use dynamic debug instead of custom infrastructure
With dynamic debug having gained the capability to report debug messages also during the boot process, it offers a far superior interface for debug messages than the custom cpufreq infrastructure. As a first step, remove the old cpufreq_debug_printk() function and replace it with a call to the generic pr_debug() function. How can dynamic debug be used on cpufreq? You need a kernel which has CONFIG_DYNAMIC_DEBUG enabled. To enabled debugging during runtime, mount debugfs and $ echo -n 'module cpufreq +p' > /sys/kernel/debug/dynamic_debug/control for debugging the complete "cpufreq" module. To achieve the same goal during boot, append ddebug_query="module cpufreq +p" as a boot parameter to the kernel of your choice. For more detailled instructions, please see Documentation/dynamic-debug-howto.txt Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c180
1 files changed, 37 insertions, 143 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7c10f96c5ae9..1e08af43ae72 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -32,9 +32,6 @@
32 32
33#include <trace/events/power.h> 33#include <trace/events/power.h>
34 34
35#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \
36 "cpufreq-core", msg)
37
38/** 35/**
39 * The "cpufreq driver" - the arch- or hardware-dependent low 36 * The "cpufreq driver" - the arch- or hardware-dependent low
40 * level driver of CPUFreq support, and its spinlock. This lock 37 * level driver of CPUFreq support, and its spinlock. This lock
@@ -181,93 +178,6 @@ EXPORT_SYMBOL_GPL(cpufreq_cpu_put);
181 178
182 179
183/********************************************************************* 180/*********************************************************************
184 * UNIFIED DEBUG HELPERS *
185 *********************************************************************/
186#ifdef CONFIG_CPU_FREQ_DEBUG
187
188/* what part(s) of the CPUfreq subsystem are debugged? */
189static unsigned int debug;
190
191/* is the debug output ratelimit'ed using printk_ratelimit? User can
192 * set or modify this value.
193 */
194static unsigned int debug_ratelimit = 1;
195
196/* is the printk_ratelimit'ing enabled? It's enabled after a successful
197 * loading of a cpufreq driver, temporarily disabled when a new policy
198 * is set, and disabled upon cpufreq driver removal
199 */
200static unsigned int disable_ratelimit = 1;
201static DEFINE_SPINLOCK(disable_ratelimit_lock);
202
203static void cpufreq_debug_enable_ratelimit(void)
204{
205 unsigned long flags;
206
207 spin_lock_irqsave(&disable_ratelimit_lock, flags);
208 if (disable_ratelimit)
209 disable_ratelimit--;
210 spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
211}
212
213static void cpufreq_debug_disable_ratelimit(void)
214{
215 unsigned long flags;
216
217 spin_lock_irqsave(&disable_ratelimit_lock, flags);
218 disable_ratelimit++;
219 spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
220}
221
222void cpufreq_debug_printk(unsigned int type, const char *prefix,
223 const char *fmt, ...)
224{
225 char s[256];
226 va_list args;
227 unsigned int len;
228 unsigned long flags;
229
230 WARN_ON(!prefix);
231 if (type & debug) {
232 spin_lock_irqsave(&disable_ratelimit_lock, flags);
233 if (!disable_ratelimit && debug_ratelimit
234 && !printk_ratelimit()) {
235 spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
236 return;
237 }
238 spin_unlock_irqrestore(&disable_ratelimit_lock, flags);
239
240 len = snprintf(s, 256, KERN_DEBUG "%s: ", prefix);
241
242 va_start(args, fmt);
243 len += vsnprintf(&s[len], (256 - len), fmt, args);
244 va_end(args);
245
246 printk(s);
247
248 WARN_ON(len < 5);
249 }
250}
251EXPORT_SYMBOL(cpufreq_debug_printk);
252
253
254module_param(debug, uint, 0644);
255MODULE_PARM_DESC(debug, "CPUfreq debugging: add 1 to debug core,"
256 " 2 to debug drivers, and 4 to debug governors.");
257
258module_param(debug_ratelimit, uint, 0644);
259MODULE_PARM_DESC(debug_ratelimit, "CPUfreq debugging:"
260 " set to 0 to disable ratelimiting.");
261
262#else /* !CONFIG_CPU_FREQ_DEBUG */
263
264static inline void cpufreq_debug_enable_ratelimit(void) { return; }
265static inline void cpufreq_debug_disable_ratelimit(void) { return; }
266
267#endif /* CONFIG_CPU_FREQ_DEBUG */
268
269
270/*********************************************************************
271 * EXTERNALLY AFFECTING FREQUENCY CHANGES * 181 * EXTERNALLY AFFECTING FREQUENCY CHANGES *
272 *********************************************************************/ 182 *********************************************************************/
273 183
@@ -291,7 +201,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
291 if (!l_p_j_ref_freq) { 201 if (!l_p_j_ref_freq) {
292 l_p_j_ref = loops_per_jiffy; 202 l_p_j_ref = loops_per_jiffy;
293 l_p_j_ref_freq = ci->old; 203 l_p_j_ref_freq = ci->old;
294 dprintk("saving %lu as reference value for loops_per_jiffy; " 204 pr_debug("saving %lu as reference value for loops_per_jiffy; "
295 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); 205 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq);
296 } 206 }
297 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) || 207 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) ||
@@ -299,7 +209,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
299 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { 209 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
300 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, 210 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq,
301 ci->new); 211 ci->new);
302 dprintk("scaling loops_per_jiffy to %lu " 212 pr_debug("scaling loops_per_jiffy to %lu "
303 "for frequency %u kHz\n", loops_per_jiffy, ci->new); 213 "for frequency %u kHz\n", loops_per_jiffy, ci->new);
304 } 214 }
305} 215}
@@ -326,7 +236,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
326 BUG_ON(irqs_disabled()); 236 BUG_ON(irqs_disabled());
327 237
328 freqs->flags = cpufreq_driver->flags; 238 freqs->flags = cpufreq_driver->flags;
329 dprintk("notification %u of frequency transition to %u kHz\n", 239 pr_debug("notification %u of frequency transition to %u kHz\n",
330 state, freqs->new); 240 state, freqs->new);
331 241
332 policy = per_cpu(cpufreq_cpu_data, freqs->cpu); 242 policy = per_cpu(cpufreq_cpu_data, freqs->cpu);
@@ -340,7 +250,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
340 if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { 250 if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
341 if ((policy) && (policy->cpu == freqs->cpu) && 251 if ((policy) && (policy->cpu == freqs->cpu) &&
342 (policy->cur) && (policy->cur != freqs->old)) { 252 (policy->cur) && (policy->cur != freqs->old)) {
343 dprintk("Warning: CPU frequency is" 253 pr_debug("Warning: CPU frequency is"
344 " %u, cpufreq assumed %u kHz.\n", 254 " %u, cpufreq assumed %u kHz.\n",
345 freqs->old, policy->cur); 255 freqs->old, policy->cur);
346 freqs->old = policy->cur; 256 freqs->old = policy->cur;
@@ -353,7 +263,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
353 263
354 case CPUFREQ_POSTCHANGE: 264 case CPUFREQ_POSTCHANGE:
355 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); 265 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
356 dprintk("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, 266 pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new,
357 (unsigned long)freqs->cpu); 267 (unsigned long)freqs->cpu);
358 trace_power_frequency(POWER_PSTATE, freqs->new, freqs->cpu); 268 trace_power_frequency(POWER_PSTATE, freqs->new, freqs->cpu);
359 trace_cpu_frequency(freqs->new, freqs->cpu); 269 trace_cpu_frequency(freqs->new, freqs->cpu);
@@ -753,7 +663,7 @@ no_policy:
753static void cpufreq_sysfs_release(struct kobject *kobj) 663static void cpufreq_sysfs_release(struct kobject *kobj)
754{ 664{
755 struct cpufreq_policy *policy = to_policy(kobj); 665 struct cpufreq_policy *policy = to_policy(kobj);
756 dprintk("last reference is dropped\n"); 666 pr_debug("last reference is dropped\n");
757 complete(&policy->kobj_unregister); 667 complete(&policy->kobj_unregister);
758} 668}
759 669
@@ -788,7 +698,7 @@ static int cpufreq_add_dev_policy(unsigned int cpu,
788 gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu)); 698 gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
789 if (gov) { 699 if (gov) {
790 policy->governor = gov; 700 policy->governor = gov;
791 dprintk("Restoring governor %s for cpu %d\n", 701 pr_debug("Restoring governor %s for cpu %d\n",
792 policy->governor->name, cpu); 702 policy->governor->name, cpu);
793 } 703 }
794#endif 704#endif
@@ -824,7 +734,7 @@ static int cpufreq_add_dev_policy(unsigned int cpu,
824 per_cpu(cpufreq_cpu_data, cpu) = managed_policy; 734 per_cpu(cpufreq_cpu_data, cpu) = managed_policy;
825 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 735 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
826 736
827 dprintk("CPU already managed, adding link\n"); 737 pr_debug("CPU already managed, adding link\n");
828 ret = sysfs_create_link(&sys_dev->kobj, 738 ret = sysfs_create_link(&sys_dev->kobj,
829 &managed_policy->kobj, 739 &managed_policy->kobj,
830 "cpufreq"); 740 "cpufreq");
@@ -865,7 +775,7 @@ static int cpufreq_add_dev_symlink(unsigned int cpu,
865 if (!cpu_online(j)) 775 if (!cpu_online(j))
866 continue; 776 continue;
867 777
868 dprintk("CPU %u already managed, adding link\n", j); 778 pr_debug("CPU %u already managed, adding link\n", j);
869 managed_policy = cpufreq_cpu_get(cpu); 779 managed_policy = cpufreq_cpu_get(cpu);
870 cpu_sys_dev = get_cpu_sysdev(j); 780 cpu_sys_dev = get_cpu_sysdev(j);
871 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, 781 ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
@@ -941,7 +851,7 @@ static int cpufreq_add_dev_interface(unsigned int cpu,
941 policy->user_policy.governor = policy->governor; 851 policy->user_policy.governor = policy->governor;
942 852
943 if (ret) { 853 if (ret) {
944 dprintk("setting policy failed\n"); 854 pr_debug("setting policy failed\n");
945 if (cpufreq_driver->exit) 855 if (cpufreq_driver->exit)
946 cpufreq_driver->exit(policy); 856 cpufreq_driver->exit(policy);
947 } 857 }
@@ -977,8 +887,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
977 if (cpu_is_offline(cpu)) 887 if (cpu_is_offline(cpu))
978 return 0; 888 return 0;
979 889
980 cpufreq_debug_disable_ratelimit(); 890 pr_debug("adding CPU %u\n", cpu);
981 dprintk("adding CPU %u\n", cpu);
982 891
983#ifdef CONFIG_SMP 892#ifdef CONFIG_SMP
984 /* check whether a different CPU already registered this 893 /* check whether a different CPU already registered this
@@ -986,7 +895,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
986 policy = cpufreq_cpu_get(cpu); 895 policy = cpufreq_cpu_get(cpu);
987 if (unlikely(policy)) { 896 if (unlikely(policy)) {
988 cpufreq_cpu_put(policy); 897 cpufreq_cpu_put(policy);
989 cpufreq_debug_enable_ratelimit();
990 return 0; 898 return 0;
991 } 899 }
992#endif 900#endif
@@ -1037,7 +945,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
1037 */ 945 */
1038 ret = cpufreq_driver->init(policy); 946 ret = cpufreq_driver->init(policy);
1039 if (ret) { 947 if (ret) {
1040 dprintk("initialization failed\n"); 948 pr_debug("initialization failed\n");
1041 goto err_unlock_policy; 949 goto err_unlock_policy;
1042 } 950 }
1043 policy->user_policy.min = policy->min; 951 policy->user_policy.min = policy->min;
@@ -1063,8 +971,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
1063 971
1064 kobject_uevent(&policy->kobj, KOBJ_ADD); 972 kobject_uevent(&policy->kobj, KOBJ_ADD);
1065 module_put(cpufreq_driver->owner); 973 module_put(cpufreq_driver->owner);
1066 dprintk("initialization complete\n"); 974 pr_debug("initialization complete\n");
1067 cpufreq_debug_enable_ratelimit();
1068 975
1069 return 0; 976 return 0;
1070 977
@@ -1088,7 +995,6 @@ err_free_policy:
1088nomem_out: 995nomem_out:
1089 module_put(cpufreq_driver->owner); 996 module_put(cpufreq_driver->owner);
1090module_out: 997module_out:
1091 cpufreq_debug_enable_ratelimit();
1092 return ret; 998 return ret;
1093} 999}
1094 1000
@@ -1112,15 +1018,13 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1112 unsigned int j; 1018 unsigned int j;
1113#endif 1019#endif
1114 1020
1115 cpufreq_debug_disable_ratelimit(); 1021 pr_debug("unregistering CPU %u\n", cpu);
1116 dprintk("unregistering CPU %u\n", cpu);
1117 1022
1118 spin_lock_irqsave(&cpufreq_driver_lock, flags); 1023 spin_lock_irqsave(&cpufreq_driver_lock, flags);
1119 data = per_cpu(cpufreq_cpu_data, cpu); 1024 data = per_cpu(cpufreq_cpu_data, cpu);
1120 1025
1121 if (!data) { 1026 if (!data) {
1122 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1027 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1123 cpufreq_debug_enable_ratelimit();
1124 unlock_policy_rwsem_write(cpu); 1028 unlock_policy_rwsem_write(cpu);
1125 return -EINVAL; 1029 return -EINVAL;
1126 } 1030 }
@@ -1132,12 +1036,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1132 * only need to unlink, put and exit 1036 * only need to unlink, put and exit
1133 */ 1037 */
1134 if (unlikely(cpu != data->cpu)) { 1038 if (unlikely(cpu != data->cpu)) {
1135 dprintk("removing link\n"); 1039 pr_debug("removing link\n");
1136 cpumask_clear_cpu(cpu, data->cpus); 1040 cpumask_clear_cpu(cpu, data->cpus);
1137 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1041 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1138 kobj = &sys_dev->kobj; 1042 kobj = &sys_dev->kobj;
1139 cpufreq_cpu_put(data); 1043 cpufreq_cpu_put(data);
1140 cpufreq_debug_enable_ratelimit();
1141 unlock_policy_rwsem_write(cpu); 1044 unlock_policy_rwsem_write(cpu);
1142 sysfs_remove_link(kobj, "cpufreq"); 1045 sysfs_remove_link(kobj, "cpufreq");
1143 return 0; 1046 return 0;
@@ -1170,7 +1073,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1170 for_each_cpu(j, data->cpus) { 1073 for_each_cpu(j, data->cpus) {
1171 if (j == cpu) 1074 if (j == cpu)
1172 continue; 1075 continue;
1173 dprintk("removing link for cpu %u\n", j); 1076 pr_debug("removing link for cpu %u\n", j);
1174#ifdef CONFIG_HOTPLUG_CPU 1077#ifdef CONFIG_HOTPLUG_CPU
1175 strncpy(per_cpu(cpufreq_cpu_governor, j), 1078 strncpy(per_cpu(cpufreq_cpu_governor, j),
1176 data->governor->name, CPUFREQ_NAME_LEN); 1079 data->governor->name, CPUFREQ_NAME_LEN);
@@ -1199,17 +1102,15 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1199 * not referenced anymore by anybody before we proceed with 1102 * not referenced anymore by anybody before we proceed with
1200 * unloading. 1103 * unloading.
1201 */ 1104 */
1202 dprintk("waiting for dropping of refcount\n"); 1105 pr_debug("waiting for dropping of refcount\n");
1203 wait_for_completion(cmp); 1106 wait_for_completion(cmp);
1204 dprintk("wait complete\n"); 1107 pr_debug("wait complete\n");
1205 1108
1206 lock_policy_rwsem_write(cpu); 1109 lock_policy_rwsem_write(cpu);
1207 if (cpufreq_driver->exit) 1110 if (cpufreq_driver->exit)
1208 cpufreq_driver->exit(data); 1111 cpufreq_driver->exit(data);
1209 unlock_policy_rwsem_write(cpu); 1112 unlock_policy_rwsem_write(cpu);
1210 1113
1211 cpufreq_debug_enable_ratelimit();
1212
1213#ifdef CONFIG_HOTPLUG_CPU 1114#ifdef CONFIG_HOTPLUG_CPU
1214 /* when the CPU which is the parent of the kobj is hotplugged 1115 /* when the CPU which is the parent of the kobj is hotplugged
1215 * offline, check for siblings, and create cpufreq sysfs interface 1116 * offline, check for siblings, and create cpufreq sysfs interface
@@ -1255,7 +1156,7 @@ static void handle_update(struct work_struct *work)
1255 struct cpufreq_policy *policy = 1156 struct cpufreq_policy *policy =
1256 container_of(work, struct cpufreq_policy, update); 1157 container_of(work, struct cpufreq_policy, update);
1257 unsigned int cpu = policy->cpu; 1158 unsigned int cpu = policy->cpu;
1258 dprintk("handle_update for cpu %u called\n", cpu); 1159 pr_debug("handle_update for cpu %u called\n", cpu);
1259 cpufreq_update_policy(cpu); 1160 cpufreq_update_policy(cpu);
1260} 1161}
1261 1162
@@ -1273,7 +1174,7 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,
1273{ 1174{
1274 struct cpufreq_freqs freqs; 1175 struct cpufreq_freqs freqs;
1275 1176
1276 dprintk("Warning: CPU frequency out of sync: cpufreq and timing " 1177 pr_debug("Warning: CPU frequency out of sync: cpufreq and timing "
1277 "core thinks of %u, is %u kHz.\n", old_freq, new_freq); 1178 "core thinks of %u, is %u kHz.\n", old_freq, new_freq);
1278 1179
1279 freqs.cpu = cpu; 1180 freqs.cpu = cpu;
@@ -1376,7 +1277,7 @@ static int cpufreq_bp_suspend(void)
1376 int cpu = smp_processor_id(); 1277 int cpu = smp_processor_id();
1377 struct cpufreq_policy *cpu_policy; 1278 struct cpufreq_policy *cpu_policy;
1378 1279
1379 dprintk("suspending cpu %u\n", cpu); 1280 pr_debug("suspending cpu %u\n", cpu);
1380 1281
1381 /* If there's no policy for the boot CPU, we have nothing to do. */ 1282 /* If there's no policy for the boot CPU, we have nothing to do. */
1382 cpu_policy = cpufreq_cpu_get(cpu); 1283 cpu_policy = cpufreq_cpu_get(cpu);
@@ -1414,7 +1315,7 @@ static void cpufreq_bp_resume(void)
1414 int cpu = smp_processor_id(); 1315 int cpu = smp_processor_id();
1415 struct cpufreq_policy *cpu_policy; 1316 struct cpufreq_policy *cpu_policy;
1416 1317
1417 dprintk("resuming cpu %u\n", cpu); 1318 pr_debug("resuming cpu %u\n", cpu);
1418 1319
1419 /* If there's no policy for the boot CPU, we have nothing to do. */ 1320 /* If there's no policy for the boot CPU, we have nothing to do. */
1420 cpu_policy = cpufreq_cpu_get(cpu); 1321 cpu_policy = cpufreq_cpu_get(cpu);
@@ -1526,7 +1427,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1526{ 1427{
1527 int retval = -EINVAL; 1428 int retval = -EINVAL;
1528 1429
1529 dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu, 1430 pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
1530 target_freq, relation); 1431 target_freq, relation);
1531 if (cpu_online(policy->cpu) && cpufreq_driver->target) 1432 if (cpu_online(policy->cpu) && cpufreq_driver->target)
1532 retval = cpufreq_driver->target(policy, target_freq, relation); 1433 retval = cpufreq_driver->target(policy, target_freq, relation);
@@ -1612,7 +1513,7 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
1612 if (!try_module_get(policy->governor->owner)) 1513 if (!try_module_get(policy->governor->owner))
1613 return -EINVAL; 1514 return -EINVAL;
1614 1515
1615 dprintk("__cpufreq_governor for CPU %u, event %u\n", 1516 pr_debug("__cpufreq_governor for CPU %u, event %u\n",
1616 policy->cpu, event); 1517 policy->cpu, event);
1617 ret = policy->governor->governor(policy, event); 1518 ret = policy->governor->governor(policy, event);
1618 1519
@@ -1713,8 +1614,7 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
1713{ 1614{
1714 int ret = 0; 1615 int ret = 0;
1715 1616
1716 cpufreq_debug_disable_ratelimit(); 1617 pr_debug("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu,
1717 dprintk("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu,
1718 policy->min, policy->max); 1618 policy->min, policy->max);
1719 1619
1720 memcpy(&policy->cpuinfo, &data->cpuinfo, 1620 memcpy(&policy->cpuinfo, &data->cpuinfo,
@@ -1751,19 +1651,19 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
1751 data->min = policy->min; 1651 data->min = policy->min;
1752 data->max = policy->max; 1652 data->max = policy->max;
1753 1653
1754 dprintk("new min and max freqs are %u - %u kHz\n", 1654 pr_debug("new min and max freqs are %u - %u kHz\n",
1755 data->min, data->max); 1655 data->min, data->max);
1756 1656
1757 if (cpufreq_driver->setpolicy) { 1657 if (cpufreq_driver->setpolicy) {
1758 data->policy = policy->policy; 1658 data->policy = policy->policy;
1759 dprintk("setting range\n"); 1659 pr_debug("setting range\n");
1760 ret = cpufreq_driver->setpolicy(policy); 1660 ret = cpufreq_driver->setpolicy(policy);
1761 } else { 1661 } else {
1762 if (policy->governor != data->governor) { 1662 if (policy->governor != data->governor) {
1763 /* save old, working values */ 1663 /* save old, working values */
1764 struct cpufreq_governor *old_gov = data->governor; 1664 struct cpufreq_governor *old_gov = data->governor;
1765 1665
1766 dprintk("governor switch\n"); 1666 pr_debug("governor switch\n");
1767 1667
1768 /* end old governor */ 1668 /* end old governor */
1769 if (data->governor) 1669 if (data->governor)
@@ -1773,7 +1673,7 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
1773 data->governor = policy->governor; 1673 data->governor = policy->governor;
1774 if (__cpufreq_governor(data, CPUFREQ_GOV_START)) { 1674 if (__cpufreq_governor(data, CPUFREQ_GOV_START)) {
1775 /* new governor failed, so re-start old one */ 1675 /* new governor failed, so re-start old one */
1776 dprintk("starting governor %s failed\n", 1676 pr_debug("starting governor %s failed\n",
1777 data->governor->name); 1677 data->governor->name);
1778 if (old_gov) { 1678 if (old_gov) {
1779 data->governor = old_gov; 1679 data->governor = old_gov;
@@ -1785,12 +1685,11 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
1785 } 1685 }
1786 /* might be a policy change, too, so fall through */ 1686 /* might be a policy change, too, so fall through */
1787 } 1687 }
1788 dprintk("governor: change or update limits\n"); 1688 pr_debug("governor: change or update limits\n");
1789 __cpufreq_governor(data, CPUFREQ_GOV_LIMITS); 1689 __cpufreq_governor(data, CPUFREQ_GOV_LIMITS);
1790 } 1690 }
1791 1691
1792error_out: 1692error_out:
1793 cpufreq_debug_enable_ratelimit();
1794 return ret; 1693 return ret;
1795} 1694}
1796 1695
@@ -1817,7 +1716,7 @@ int cpufreq_update_policy(unsigned int cpu)
1817 goto fail; 1716 goto fail;
1818 } 1717 }
1819 1718
1820 dprintk("updating policy for CPU %u\n", cpu); 1719 pr_debug("updating policy for CPU %u\n", cpu);
1821 memcpy(&policy, data, sizeof(struct cpufreq_policy)); 1720 memcpy(&policy, data, sizeof(struct cpufreq_policy));
1822 policy.min = data->user_policy.min; 1721 policy.min = data->user_policy.min;
1823 policy.max = data->user_policy.max; 1722 policy.max = data->user_policy.max;
@@ -1829,7 +1728,7 @@ int cpufreq_update_policy(unsigned int cpu)
1829 if (cpufreq_driver->get) { 1728 if (cpufreq_driver->get) {
1830 policy.cur = cpufreq_driver->get(cpu); 1729 policy.cur = cpufreq_driver->get(cpu);
1831 if (!data->cur) { 1730 if (!data->cur) {
1832 dprintk("Driver did not initialize current freq"); 1731 pr_debug("Driver did not initialize current freq");
1833 data->cur = policy.cur; 1732 data->cur = policy.cur;
1834 } else { 1733 } else {
1835 if (data->cur != policy.cur) 1734 if (data->cur != policy.cur)
@@ -1905,7 +1804,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1905 ((!driver_data->setpolicy) && (!driver_data->target))) 1804 ((!driver_data->setpolicy) && (!driver_data->target)))
1906 return -EINVAL; 1805 return -EINVAL;
1907 1806
1908 dprintk("trying to register driver %s\n", driver_data->name); 1807 pr_debug("trying to register driver %s\n", driver_data->name);
1909 1808
1910 if (driver_data->setpolicy) 1809 if (driver_data->setpolicy)
1911 driver_data->flags |= CPUFREQ_CONST_LOOPS; 1810 driver_data->flags |= CPUFREQ_CONST_LOOPS;
@@ -1936,15 +1835,14 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1936 1835
1937 /* if all ->init() calls failed, unregister */ 1836 /* if all ->init() calls failed, unregister */
1938 if (ret) { 1837 if (ret) {
1939 dprintk("no CPU initialized for driver %s\n", 1838 pr_debug("no CPU initialized for driver %s\n",
1940 driver_data->name); 1839 driver_data->name);
1941 goto err_sysdev_unreg; 1840 goto err_sysdev_unreg;
1942 } 1841 }
1943 } 1842 }
1944 1843
1945 register_hotcpu_notifier(&cpufreq_cpu_notifier); 1844 register_hotcpu_notifier(&cpufreq_cpu_notifier);
1946 dprintk("driver %s up and running\n", driver_data->name); 1845 pr_debug("driver %s up and running\n", driver_data->name);
1947 cpufreq_debug_enable_ratelimit();
1948 1846
1949 return 0; 1847 return 0;
1950err_sysdev_unreg: 1848err_sysdev_unreg:
@@ -1971,14 +1869,10 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
1971{ 1869{
1972 unsigned long flags; 1870 unsigned long flags;
1973 1871
1974 cpufreq_debug_disable_ratelimit(); 1872 if (!cpufreq_driver || (driver != cpufreq_driver))
1975
1976 if (!cpufreq_driver || (driver != cpufreq_driver)) {
1977 cpufreq_debug_enable_ratelimit();
1978 return -EINVAL; 1873 return -EINVAL;
1979 }
1980 1874
1981 dprintk("unregistering driver %s\n", driver->name); 1875 pr_debug("unregistering driver %s\n", driver->name);
1982 1876
1983 sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); 1877 sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver);
1984 unregister_hotcpu_notifier(&cpufreq_cpu_notifier); 1878 unregister_hotcpu_notifier(&cpufreq_cpu_notifier);