aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-06-19 04:49:33 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-06-20 19:06:34 -0400
commitbb176f7d038fee4d46b3293e64e173bfb05ab7b5 (patch)
tree3083ebddffa88ffe7e4889dc1ba618bb55c89953 /drivers/cpufreq/cpufreq.c
parent95731ebb114c5f0c028459388560fc2a72fe5049 (diff)
cpufreq: Fix minor formatting issues
There were a few noticeable formatting issues in core cpufreq code. This cleans them up to make code look better. The changes include: - Whitespace cleanup. - Rearrangements of code. - Multiline comments fixes. - Formatting changes to fit 80 columns. Copyright information in cpufreq.c is also updated to include my name for 2013. [rjw: Changelog] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c63
1 files changed, 27 insertions, 36 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 43cf60832468..075edeff358c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001 Russell King 4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org>
6 * 7 *
7 * Oct 2005 - Ashok Raj <ashok.raj@intel.com> 8 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>
8 * Added handling for CPU hotplug 9 * Added handling for CPU hotplug
@@ -12,7 +13,6 @@
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as 14 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation. 15 * published by the Free Software Foundation.
15 *
16 */ 16 */
17 17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -44,12 +44,13 @@
44 */ 44 */
45static struct cpufreq_driver *cpufreq_driver; 45static struct cpufreq_driver *cpufreq_driver;
46static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); 46static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
47static DEFINE_RWLOCK(cpufreq_driver_lock);
48static DEFINE_MUTEX(cpufreq_governor_lock);
49
47#ifdef CONFIG_HOTPLUG_CPU 50#ifdef CONFIG_HOTPLUG_CPU
48/* This one keeps track of the previously set governor of a removed CPU */ 51/* This one keeps track of the previously set governor of a removed CPU */
49static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); 52static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
50#endif 53#endif
51static DEFINE_RWLOCK(cpufreq_driver_lock);
52static DEFINE_MUTEX(cpufreq_governor_lock);
53 54
54/* 55/*
55 * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure 56 * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure
@@ -199,7 +200,6 @@ static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs)
199 if (!try_module_get(cpufreq_driver->owner)) 200 if (!try_module_get(cpufreq_driver->owner))
200 goto err_out_unlock; 201 goto err_out_unlock;
201 202
202
203 /* get the CPU */ 203 /* get the CPU */
204 data = per_cpu(cpufreq_cpu_data, cpu); 204 data = per_cpu(cpufreq_cpu_data, cpu);
205 205
@@ -269,7 +269,7 @@ static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data)
269 */ 269 */
270#ifndef CONFIG_SMP 270#ifndef CONFIG_SMP
271static unsigned long l_p_j_ref; 271static unsigned long l_p_j_ref;
272static unsigned int l_p_j_ref_freq; 272static unsigned int l_p_j_ref_freq;
273 273
274static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) 274static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
275{ 275{
@@ -282,7 +282,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
282 pr_debug("saving %lu as reference value for loops_per_jiffy; " 282 pr_debug("saving %lu as reference value for loops_per_jiffy; "
283 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); 283 "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq);
284 } 284 }
285 if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) || 285 if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) ||
286 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { 286 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
287 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, 287 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq,
288 ci->new); 288 ci->new);
@@ -297,7 +297,6 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
297} 297}
298#endif 298#endif
299 299
300
301void __cpufreq_notify_transition(struct cpufreq_policy *policy, 300void __cpufreq_notify_transition(struct cpufreq_policy *policy,
302 struct cpufreq_freqs *freqs, unsigned int state) 301 struct cpufreq_freqs *freqs, unsigned int state)
303{ 302{
@@ -343,6 +342,7 @@ void __cpufreq_notify_transition(struct cpufreq_policy *policy,
343 break; 342 break;
344 } 343 }
345} 344}
345
346/** 346/**
347 * cpufreq_notify_transition - call notifier chain and adjust_jiffies 347 * cpufreq_notify_transition - call notifier chain and adjust_jiffies
348 * on frequency transition. 348 * on frequency transition.
@@ -360,7 +360,6 @@ void cpufreq_notify_transition(struct cpufreq_policy *policy,
360EXPORT_SYMBOL_GPL(cpufreq_notify_transition); 360EXPORT_SYMBOL_GPL(cpufreq_notify_transition);
361 361
362 362
363
364/********************************************************************* 363/*********************************************************************
365 * SYSFS INTERFACE * 364 * SYSFS INTERFACE *
366 *********************************************************************/ 365 *********************************************************************/
@@ -425,7 +424,6 @@ out:
425 return err; 424 return err;
426} 425}
427 426
428
429/** 427/**
430 * cpufreq_per_cpu_attr_read() / show_##file_name() - 428 * cpufreq_per_cpu_attr_read() / show_##file_name() -
431 * print out cpufreq information 429 * print out cpufreq information
@@ -490,7 +488,6 @@ static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy,
490 return sprintf(buf, "%u\n", cur_freq); 488 return sprintf(buf, "%u\n", cur_freq);
491} 489}
492 490
493
494/** 491/**
495 * show_scaling_governor - show the current policy for the specified CPU 492 * show_scaling_governor - show the current policy for the specified CPU
496 */ 493 */
@@ -506,7 +503,6 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf)
506 return -EINVAL; 503 return -EINVAL;
507} 504}
508 505
509
510/** 506/**
511 * store_scaling_governor - store policy for the specified CPU 507 * store_scaling_governor - store policy for the specified CPU
512 */ 508 */
@@ -529,8 +525,10 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
529 &new_policy.governor)) 525 &new_policy.governor))
530 return -EINVAL; 526 return -EINVAL;
531 527
532 /* Do not use cpufreq_set_policy here or the user_policy.max 528 /*
533 will be wrongly overridden */ 529 * Do not use cpufreq_set_policy here or the user_policy.max
530 * will be wrongly overridden
531 */
534 ret = __cpufreq_set_policy(policy, &new_policy); 532 ret = __cpufreq_set_policy(policy, &new_policy);
535 533
536 policy->user_policy.policy = policy->policy; 534 policy->user_policy.policy = policy->policy;
@@ -1094,7 +1092,8 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
1094 * Caller should already have policy_rwsem in write mode for this CPU. 1092 * Caller should already have policy_rwsem in write mode for this CPU.
1095 * This routine frees the rwsem before returning. 1093 * This routine frees the rwsem before returning.
1096 */ 1094 */
1097static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) 1095static int __cpufreq_remove_dev(struct device *dev,
1096 struct subsys_interface *sif)
1098{ 1097{
1099 unsigned int cpu = dev->id, ret, cpus; 1098 unsigned int cpu = dev->id, ret, cpus;
1100 unsigned long flags; 1099 unsigned long flags;
@@ -1201,7 +1200,6 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif
1201 return 0; 1200 return 0;
1202} 1201}
1203 1202
1204
1205static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) 1203static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
1206{ 1204{
1207 unsigned int cpu = dev->id; 1205 unsigned int cpu = dev->id;
@@ -1214,7 +1212,6 @@ static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
1214 return retval; 1212 return retval;
1215} 1213}
1216 1214
1217
1218static void handle_update(struct work_struct *work) 1215static void handle_update(struct work_struct *work)
1219{ 1216{
1220 struct cpufreq_policy *policy = 1217 struct cpufreq_policy *policy =
@@ -1225,7 +1222,8 @@ static void handle_update(struct work_struct *work)
1225} 1222}
1226 1223
1227/** 1224/**
1228 * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're in deep trouble. 1225 * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're
1226 * in deep trouble.
1229 * @cpu: cpu number 1227 * @cpu: cpu number
1230 * @old_freq: CPU frequency the kernel thinks the CPU runs at 1228 * @old_freq: CPU frequency the kernel thinks the CPU runs at
1231 * @new_freq: CPU frequency the CPU actually runs at 1229 * @new_freq: CPU frequency the CPU actually runs at
@@ -1240,7 +1238,6 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,
1240 struct cpufreq_freqs freqs; 1238 struct cpufreq_freqs freqs;
1241 unsigned long flags; 1239 unsigned long flags;
1242 1240
1243
1244 pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " 1241 pr_debug("Warning: CPU frequency out of sync: cpufreq and timing "
1245 "core thinks of %u, is %u kHz.\n", old_freq, new_freq); 1242 "core thinks of %u, is %u kHz.\n", old_freq, new_freq);
1246 1243
@@ -1255,7 +1252,6 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,
1255 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); 1252 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
1256} 1253}
1257 1254
1258
1259/** 1255/**
1260 * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur 1256 * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur
1261 * @cpu: CPU number 1257 * @cpu: CPU number
@@ -1301,7 +1297,6 @@ unsigned int cpufreq_quick_get_max(unsigned int cpu)
1301} 1297}
1302EXPORT_SYMBOL(cpufreq_quick_get_max); 1298EXPORT_SYMBOL(cpufreq_quick_get_max);
1303 1299
1304
1305static unsigned int __cpufreq_get(unsigned int cpu) 1300static unsigned int __cpufreq_get(unsigned int cpu)
1306{ 1301{
1307 struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); 1302 struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
@@ -1360,7 +1355,6 @@ static struct subsys_interface cpufreq_interface = {
1360 .remove_dev = cpufreq_remove_dev, 1355 .remove_dev = cpufreq_remove_dev,
1361}; 1356};
1362 1357
1363
1364/** 1358/**
1365 * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. 1359 * cpufreq_bp_suspend - Prepare the boot CPU for system suspend.
1366 * 1360 *
@@ -1497,11 +1491,10 @@ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list)
1497} 1491}
1498EXPORT_SYMBOL(cpufreq_register_notifier); 1492EXPORT_SYMBOL(cpufreq_register_notifier);
1499 1493
1500
1501/** 1494/**
1502 * cpufreq_unregister_notifier - unregister a driver with cpufreq 1495 * cpufreq_unregister_notifier - unregister a driver with cpufreq
1503 * @nb: notifier block to be unregistered 1496 * @nb: notifier block to be unregistered
1504 * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER 1497 * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER
1505 * 1498 *
1506 * Remove a driver from the CPU frequency notifier list. 1499 * Remove a driver from the CPU frequency notifier list.
1507 * 1500 *
@@ -1537,7 +1530,6 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier);
1537 * GOVERNORS * 1530 * GOVERNORS *
1538 *********************************************************************/ 1531 *********************************************************************/
1539 1532
1540
1541int __cpufreq_driver_target(struct cpufreq_policy *policy, 1533int __cpufreq_driver_target(struct cpufreq_policy *policy,
1542 unsigned int target_freq, 1534 unsigned int target_freq,
1543 unsigned int relation) 1535 unsigned int relation)
@@ -1678,7 +1670,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
1678 return ret; 1670 return ret;
1679} 1671}
1680 1672
1681
1682int cpufreq_register_governor(struct cpufreq_governor *governor) 1673int cpufreq_register_governor(struct cpufreq_governor *governor)
1683{ 1674{
1684 int err; 1675 int err;
@@ -1703,7 +1694,6 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1703} 1694}
1704EXPORT_SYMBOL_GPL(cpufreq_register_governor); 1695EXPORT_SYMBOL_GPL(cpufreq_register_governor);
1705 1696
1706
1707void cpufreq_unregister_governor(struct cpufreq_governor *governor) 1697void cpufreq_unregister_governor(struct cpufreq_governor *governor)
1708{ 1698{
1709#ifdef CONFIG_HOTPLUG_CPU 1699#ifdef CONFIG_HOTPLUG_CPU
@@ -1733,7 +1723,6 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
1733EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); 1723EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
1734 1724
1735 1725
1736
1737/********************************************************************* 1726/*********************************************************************
1738 * POLICY INTERFACE * 1727 * POLICY INTERFACE *
1739 *********************************************************************/ 1728 *********************************************************************/
@@ -1762,7 +1751,6 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
1762} 1751}
1763EXPORT_SYMBOL(cpufreq_get_policy); 1752EXPORT_SYMBOL(cpufreq_get_policy);
1764 1753
1765
1766/* 1754/*
1767 * data : current policy. 1755 * data : current policy.
1768 * policy : policy to be set. 1756 * policy : policy to be set.
@@ -1796,8 +1784,10 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
1796 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 1784 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1797 CPUFREQ_INCOMPATIBLE, policy); 1785 CPUFREQ_INCOMPATIBLE, policy);
1798 1786
1799 /* verify the cpu speed can be set within this limit, 1787 /*
1800 which might be different to the first one */ 1788 * verify the cpu speed can be set within this limit, which might be
1789 * different to the first one
1790 */
1801 ret = cpufreq_driver->verify(policy); 1791 ret = cpufreq_driver->verify(policy);
1802 if (ret) 1792 if (ret)
1803 goto error_out; 1793 goto error_out;
@@ -1899,8 +1889,10 @@ int cpufreq_update_policy(unsigned int cpu)
1899 policy.policy = data->user_policy.policy; 1889 policy.policy = data->user_policy.policy;
1900 policy.governor = data->user_policy.governor; 1890 policy.governor = data->user_policy.governor;
1901 1891
1902 /* BIOS might change freq behind our back 1892 /*
1903 -> ask driver for current freq and notify governors about a change */ 1893 * BIOS might change freq behind our back
1894 * -> ask driver for current freq and notify governors about a change
1895 */
1904 if (cpufreq_driver->get) { 1896 if (cpufreq_driver->get) {
1905 policy.cur = cpufreq_driver->get(cpu); 1897 policy.cur = cpufreq_driver->get(cpu);
1906 if (!data->cur) { 1898 if (!data->cur) {
@@ -1949,7 +1941,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
1949} 1941}
1950 1942
1951static struct notifier_block __refdata cpufreq_cpu_notifier = { 1943static struct notifier_block __refdata cpufreq_cpu_notifier = {
1952 .notifier_call = cpufreq_cpu_callback, 1944 .notifier_call = cpufreq_cpu_callback,
1953}; 1945};
1954 1946
1955/********************************************************************* 1947/*********************************************************************
@@ -1961,7 +1953,7 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = {
1961 * @driver_data: A struct cpufreq_driver containing the values# 1953 * @driver_data: A struct cpufreq_driver containing the values#
1962 * submitted by the CPU Frequency driver. 1954 * submitted by the CPU Frequency driver.
1963 * 1955 *
1964 * Registers a CPU Frequency driver to this core code. This code 1956 * Registers a CPU Frequency driver to this core code. This code
1965 * returns zero on success, -EBUSY when another driver got here first 1957 * returns zero on success, -EBUSY when another driver got here first
1966 * (and isn't unregistered in the meantime). 1958 * (and isn't unregistered in the meantime).
1967 * 1959 *
@@ -2028,11 +2020,10 @@ err_null_driver:
2028} 2020}
2029EXPORT_SYMBOL_GPL(cpufreq_register_driver); 2021EXPORT_SYMBOL_GPL(cpufreq_register_driver);
2030 2022
2031
2032/** 2023/**
2033 * cpufreq_unregister_driver - unregister the current CPUFreq driver 2024 * cpufreq_unregister_driver - unregister the current CPUFreq driver
2034 * 2025 *
2035 * Unregister the current CPUFreq driver. Only call this if you have 2026 * Unregister the current CPUFreq driver. Only call this if you have
2036 * the right to do so, i.e. if you have succeeded in initialising before! 2027 * the right to do so, i.e. if you have succeeded in initialising before!
2037 * Returns zero if successful, and -EINVAL if the cpufreq_driver is 2028 * Returns zero if successful, and -EINVAL if the cpufreq_driver is
2038 * currently not initialised. 2029 * currently not initialised.