aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 9b6ae7dc8b8a..9759d05b1972 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -319,7 +319,6 @@ out:
319 } 319 }
320 return -EINVAL; 320 return -EINVAL;
321} 321}
322EXPORT_SYMBOL_GPL(cpufreq_parse_governor);
323 322
324 323
325/* drivers/base/cpu.c */ 324/* drivers/base/cpu.c */
@@ -346,6 +345,8 @@ show_one(scaling_min_freq, min);
346show_one(scaling_max_freq, max); 345show_one(scaling_max_freq, max);
347show_one(scaling_cur_freq, cur); 346show_one(scaling_cur_freq, cur);
348 347
348static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy);
349
349/** 350/**
350 * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access 351 * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
351 */ 352 */
@@ -364,7 +365,10 @@ static ssize_t store_##file_name \
364 if (ret != 1) \ 365 if (ret != 1) \
365 return -EINVAL; \ 366 return -EINVAL; \
366 \ 367 \
367 ret = cpufreq_set_policy(&new_policy); \ 368 mutex_lock(&policy->lock); \
369 ret = __cpufreq_set_policy(policy, &new_policy); \
370 policy->user_policy.object = policy->object; \
371 mutex_unlock(&policy->lock); \
368 \ 372 \
369 return ret ? ret : count; \ 373 return ret ? ret : count; \
370} 374}
@@ -420,7 +424,15 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy,
420 if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor)) 424 if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor))
421 return -EINVAL; 425 return -EINVAL;
422 426
423 ret = cpufreq_set_policy(&new_policy); 427 /* Do not use cpufreq_set_policy here or the user_policy.max
428 will be wrongly overridden */
429 mutex_lock(&policy->lock);
430 ret = __cpufreq_set_policy(policy, &new_policy);
431
432 policy->user_policy.policy = policy->policy;
433 policy->user_policy.governor = policy->governor;
434 mutex_unlock(&policy->lock);
435
424 return ret ? ret : count; 436 return ret ? ret : count;
425} 437}
426 438
@@ -685,7 +697,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
685 if (!cpu_online(j)) 697 if (!cpu_online(j))
686 continue; 698 continue;
687 699
688 dprintk("CPU already managed, adding link\n"); 700 dprintk("CPU %u already managed, adding link\n", j);
689 cpufreq_cpu_get(cpu); 701 cpufreq_cpu_get(cpu);
690 cpu_sys_dev = get_cpu_sysdev(j); 702 cpu_sys_dev = get_cpu_sysdev(j);
691 sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, 703 sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
@@ -695,9 +707,8 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
695 policy->governor = NULL; /* to assure that the starting sequence is 707 policy->governor = NULL; /* to assure that the starting sequence is
696 * run in cpufreq_set_policy */ 708 * run in cpufreq_set_policy */
697 mutex_unlock(&policy->lock); 709 mutex_unlock(&policy->lock);
698 710
699 /* set default policy */ 711 /* set default policy */
700
701 ret = cpufreq_set_policy(&new_policy); 712 ret = cpufreq_set_policy(&new_policy);
702 if (ret) { 713 if (ret) {
703 dprintk("setting policy failed\n"); 714 dprintk("setting policy failed\n");
@@ -707,7 +718,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
707 module_put(cpufreq_driver->owner); 718 module_put(cpufreq_driver->owner);
708 dprintk("initialization complete\n"); 719 dprintk("initialization complete\n");
709 cpufreq_debug_enable_ratelimit(); 720 cpufreq_debug_enable_ratelimit();
710 721
711 return 0; 722 return 0;
712 723
713 724