cpufreq.c (b675b3667f6729dcd1036a2a129b35445947f905) cpufreq.c (a7b422cda5084db7265c3b23310a959b43b47529)
1/*
2 * linux/drivers/cpufreq/cpufreq.c
3 *
4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 *
7 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>
8 * Added handling for CPU hotplug

--- 112 unchanged lines hidden (view full) ---

121static int __init init_cpufreq_transition_notifier_list(void)
122{
123 srcu_init_notifier_head(&cpufreq_transition_notifier_list);
124 init_cpufreq_transition_notifier_list_called = true;
125 return 0;
126}
127pure_initcall(init_cpufreq_transition_notifier_list);
128
1/*
2 * linux/drivers/cpufreq/cpufreq.c
3 *
4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 *
7 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>
8 * Added handling for CPU hotplug

--- 112 unchanged lines hidden (view full) ---

121static int __init init_cpufreq_transition_notifier_list(void)
122{
123 srcu_init_notifier_head(&cpufreq_transition_notifier_list);
124 init_cpufreq_transition_notifier_list_called = true;
125 return 0;
126}
127pure_initcall(init_cpufreq_transition_notifier_list);
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);
130static DEFINE_MUTEX(cpufreq_governor_mutex);
131
132struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
133{
134 struct cpufreq_policy *data;
135 unsigned long flags;
136

--- 1299 unchanged lines hidden (view full) ---

1436
1437
1438int __cpufreq_driver_target(struct cpufreq_policy *policy,
1439 unsigned int target_freq,
1440 unsigned int relation)
1441{
1442 int retval = -EINVAL;
1443
138static LIST_HEAD(cpufreq_governor_list);
139static DEFINE_MUTEX(cpufreq_governor_mutex);
140
141struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
142{
143 struct cpufreq_policy *data;
144 unsigned long flags;
145

--- 1299 unchanged lines hidden (view full) ---

1445
1446
1447int __cpufreq_driver_target(struct cpufreq_policy *policy,
1448 unsigned int target_freq,
1449 unsigned int relation)
1450{
1451 int retval = -EINVAL;
1452
1453 if (cpufreq_disabled())
1454 return -ENODEV;
1455
1444 pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
1445 target_freq, relation);
1446 if (cpu_online(policy->cpu) && cpufreq_driver->target)
1447 retval = cpufreq_driver->target(policy, target_freq, relation);
1448
1449 return retval;
1450}
1451EXPORT_SYMBOL_GPL(__cpufreq_driver_target);

--- 92 unchanged lines hidden (view full) ---

1544
1545int cpufreq_register_governor(struct cpufreq_governor *governor)
1546{
1547 int err;
1548
1549 if (!governor)
1550 return -EINVAL;
1551
1456 pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
1457 target_freq, relation);
1458 if (cpu_online(policy->cpu) && cpufreq_driver->target)
1459 retval = cpufreq_driver->target(policy, target_freq, relation);
1460
1461 return retval;
1462}
1463EXPORT_SYMBOL_GPL(__cpufreq_driver_target);

--- 92 unchanged lines hidden (view full) ---

1556
1557int cpufreq_register_governor(struct cpufreq_governor *governor)
1558{
1559 int err;
1560
1561 if (!governor)
1562 return -EINVAL;
1563
1564 if (cpufreq_disabled())
1565 return -ENODEV;
1566
1552 mutex_lock(&cpufreq_governor_mutex);
1553
1554 err = -EBUSY;
1555 if (__find_governor(governor->name) == NULL) {
1556 err = 0;
1557 list_add(&governor->governor_list, &cpufreq_governor_list);
1558 }
1559

--- 7 unchanged lines hidden (view full) ---

1567{
1568#ifdef CONFIG_HOTPLUG_CPU
1569 int cpu;
1570#endif
1571
1572 if (!governor)
1573 return;
1574
1567 mutex_lock(&cpufreq_governor_mutex);
1568
1569 err = -EBUSY;
1570 if (__find_governor(governor->name) == NULL) {
1571 err = 0;
1572 list_add(&governor->governor_list, &cpufreq_governor_list);
1573 }
1574

--- 7 unchanged lines hidden (view full) ---

1582{
1583#ifdef CONFIG_HOTPLUG_CPU
1584 int cpu;
1585#endif
1586
1587 if (!governor)
1588 return;
1589
1590 if (cpufreq_disabled())
1591 return;
1592
1575#ifdef CONFIG_HOTPLUG_CPU
1576 for_each_present_cpu(cpu) {
1577 if (cpu_online(cpu))
1578 continue;
1579 if (!strcmp(per_cpu(cpufreq_cpu_governor, cpu), governor->name))
1580 strcpy(per_cpu(cpufreq_cpu_governor, cpu), "\0");
1581 }
1582#endif

--- 226 unchanged lines hidden (view full) ---

1809 * (and isn't unregistered in the meantime).
1810 *
1811 */
1812int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1813{
1814 unsigned long flags;
1815 int ret;
1816
1593#ifdef CONFIG_HOTPLUG_CPU
1594 for_each_present_cpu(cpu) {
1595 if (cpu_online(cpu))
1596 continue;
1597 if (!strcmp(per_cpu(cpufreq_cpu_governor, cpu), governor->name))
1598 strcpy(per_cpu(cpufreq_cpu_governor, cpu), "\0");
1599 }
1600#endif

--- 226 unchanged lines hidden (view full) ---

1827 * (and isn't unregistered in the meantime).
1828 *
1829 */
1830int cpufreq_register_driver(struct cpufreq_driver *driver_data)
1831{
1832 unsigned long flags;
1833 int ret;
1834
1835 if (cpufreq_disabled())
1836 return -ENODEV;
1837
1817 if (!driver_data || !driver_data->verify || !driver_data->init ||
1818 ((!driver_data->setpolicy) && (!driver_data->target)))
1819 return -EINVAL;
1820
1821 pr_debug("trying to register driver %s\n", driver_data->name);
1822
1823 if (driver_data->setpolicy)
1824 driver_data->flags |= CPUFREQ_CONST_LOOPS;

--- 71 unchanged lines hidden (view full) ---

1896 return 0;
1897}
1898EXPORT_SYMBOL_GPL(cpufreq_unregister_driver);
1899
1900static int __init cpufreq_core_init(void)
1901{
1902 int cpu;
1903
1838 if (!driver_data || !driver_data->verify || !driver_data->init ||
1839 ((!driver_data->setpolicy) && (!driver_data->target)))
1840 return -EINVAL;
1841
1842 pr_debug("trying to register driver %s\n", driver_data->name);
1843
1844 if (driver_data->setpolicy)
1845 driver_data->flags |= CPUFREQ_CONST_LOOPS;

--- 71 unchanged lines hidden (view full) ---

1917 return 0;
1918}
1919EXPORT_SYMBOL_GPL(cpufreq_unregister_driver);
1920
1921static int __init cpufreq_core_init(void)
1922{
1923 int cpu;
1924
1925 if (cpufreq_disabled())
1926 return -ENODEV;
1927
1904 for_each_possible_cpu(cpu) {
1905 per_cpu(cpufreq_policy_cpu, cpu) = -1;
1906 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));
1907 }
1908
1909 cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj);
1910 BUG_ON(!cpufreq_global_kobject);
1911 register_syscore_ops(&cpufreq_syscore_ops);
1912
1913 return 0;
1914}
1915core_initcall(cpufreq_core_init);
1928 for_each_possible_cpu(cpu) {
1929 per_cpu(cpufreq_policy_cpu, cpu) = -1;
1930 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));
1931 }
1932
1933 cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj);
1934 BUG_ON(!cpufreq_global_kobject);
1935 register_syscore_ops(&cpufreq_syscore_ops);
1936
1937 return 0;
1938}
1939core_initcall(cpufreq_core_init);