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.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 622013fb7890..7f2f149ae40f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -126,6 +126,15 @@ static int __init init_cpufreq_transition_notifier_list(void)
126} 126}
127pure_initcall(init_cpufreq_transition_notifier_list); 127pure_initcall(init_cpufreq_transition_notifier_list);
128 128
129static int off __read_mostly;
130int cpufreq_disabled(void)
131{
132 return off;
133}
134void disable_cpufreq(void)
135{
136 off = 1;
137}
129static LIST_HEAD(cpufreq_governor_list); 138static LIST_HEAD(cpufreq_governor_list);
130static DEFINE_MUTEX(cpufreq_governor_mutex); 139static DEFINE_MUTEX(cpufreq_governor_mutex);
131 140
@@ -1441,6 +1450,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1441{ 1450{
1442 int retval = -EINVAL; 1451 int retval = -EINVAL;
1443 1452
1453 if (cpufreq_disabled())
1454 return -ENODEV;
1455
1444 pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, 1456 pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
1445 target_freq, relation); 1457 target_freq, relation);
1446 if (cpu_online(policy->cpu) && cpufreq_driver->target) 1458 if (cpu_online(policy->cpu) && cpufreq_driver->target)
@@ -1549,6 +1561,9 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1549 if (!governor) 1561 if (!governor)
1550 return -EINVAL; 1562 return -EINVAL;
1551 1563
1564 if (cpufreq_disabled())
1565 return -ENODEV;
1566
1552 mutex_lock(&cpufreq_governor_mutex); 1567 mutex_lock(&cpufreq_governor_mutex);
1553 1568
1554 err = -EBUSY; 1569 err = -EBUSY;
@@ -1572,6 +1587,9 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
1572 if (!governor) 1587 if (!governor)
1573 return; 1588 return;
1574 1589
1590 if (cpufreq_disabled())
1591 return;
1592
1575#ifdef CONFIG_HOTPLUG_CPU 1593#ifdef CONFIG_HOTPLUG_CPU
1576 for_each_present_cpu(cpu) { 1594 for_each_present_cpu(cpu) {
1577 if (cpu_online(cpu)) 1595 if (cpu_online(cpu))
@@ -1814,6 +1832,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1814 unsigned long flags; 1832 unsigned long flags;
1815 int ret; 1833 int ret;
1816 1834
1835 if (cpufreq_disabled())
1836 return -ENODEV;
1837
1817 if (!driver_data || !driver_data->verify || !driver_data->init || 1838 if (!driver_data || !driver_data->verify || !driver_data->init ||
1818 ((!driver_data->setpolicy) && (!driver_data->target))) 1839 ((!driver_data->setpolicy) && (!driver_data->target)))
1819 return -EINVAL; 1840 return -EINVAL;
@@ -1901,6 +1922,9 @@ static int __init cpufreq_core_init(void)
1901{ 1922{
1902 int cpu; 1923 int cpu;
1903 1924
1925 if (cpufreq_disabled())
1926 return -ENODEV;
1927
1904 for_each_possible_cpu(cpu) { 1928 for_each_possible_cpu(cpu) {
1905 per_cpu(cpufreq_policy_cpu, cpu) = -1; 1929 per_cpu(cpufreq_policy_cpu, cpu) = -1;
1906 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); 1930 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));