Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Viresh Kumar and committed by
Rafael J. Wysocki
bb176f7d 95731ebb

+53 -73
+27 -36
drivers/cpufreq/cpufreq.c
··· 3 3 * 4 4 * Copyright (C) 2001 Russell King 5 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 6 + * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org> 6 7 * 7 8 * Oct 2005 - Ashok Raj <ashok.raj@intel.com> 8 9 * Added handling for CPU hotplug ··· 13 12 * This program is free software; you can redistribute it and/or modify 14 13 * it under the terms of the GNU General Public License version 2 as 15 14 * published by the Free Software Foundation. 16 - * 17 15 */ 18 16 19 17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ··· 44 44 */ 45 45 static struct cpufreq_driver *cpufreq_driver; 46 46 static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); 47 + static DEFINE_RWLOCK(cpufreq_driver_lock); 48 + static DEFINE_MUTEX(cpufreq_governor_lock); 49 + 47 50 #ifdef CONFIG_HOTPLUG_CPU 48 51 /* This one keeps track of the previously set governor of a removed CPU */ 49 52 static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); 50 53 #endif 51 - static DEFINE_RWLOCK(cpufreq_driver_lock); 52 - static DEFINE_MUTEX(cpufreq_governor_lock); 53 54 54 55 /* 55 56 * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure ··· 200 199 if (!try_module_get(cpufreq_driver->owner)) 201 200 goto err_out_unlock; 202 201 203 - 204 202 /* get the CPU */ 205 203 data = per_cpu(cpufreq_cpu_data, cpu); 206 204 ··· 269 269 */ 270 270 #ifndef CONFIG_SMP 271 271 static unsigned long l_p_j_ref; 272 - static unsigned int l_p_j_ref_freq; 272 + static unsigned int l_p_j_ref_freq; 273 273 274 274 static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) 275 275 { ··· 282 282 pr_debug("saving %lu as reference value for loops_per_jiffy; " 283 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 286 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { 287 287 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, 288 288 ci->new); ··· 296 296 return; 297 297 } 298 298 #endif 299 - 300 299 301 300 void __cpufreq_notify_transition(struct cpufreq_policy *policy, 302 301 struct cpufreq_freqs *freqs, unsigned int state) ··· 342 343 break; 343 344 } 344 345 } 346 + 345 347 /** 346 348 * cpufreq_notify_transition - call notifier chain and adjust_jiffies 347 349 * on frequency transition. ··· 358 358 __cpufreq_notify_transition(policy, freqs, state); 359 359 } 360 360 EXPORT_SYMBOL_GPL(cpufreq_notify_transition); 361 - 362 361 363 362 364 363 /********************************************************************* ··· 424 425 return err; 425 426 } 426 427 427 - 428 428 /** 429 429 * cpufreq_per_cpu_attr_read() / show_##file_name() - 430 430 * print out cpufreq information ··· 488 490 return sprintf(buf, "%u\n", cur_freq); 489 491 } 490 492 491 - 492 493 /** 493 494 * show_scaling_governor - show the current policy for the specified CPU 494 495 */ ··· 502 505 policy->governor->name); 503 506 return -EINVAL; 504 507 } 505 - 506 508 507 509 /** 508 510 * store_scaling_governor - store policy for the specified CPU ··· 525 529 &new_policy.governor)) 526 530 return -EINVAL; 527 531 528 - /* Do not use cpufreq_set_policy here or the user_policy.max 529 - will be wrongly overridden */ 532 + /* 533 + * Do not use cpufreq_set_policy here or the user_policy.max 534 + * will be wrongly overridden 535 + */ 530 536 ret = __cpufreq_set_policy(policy, &new_policy); 531 537 532 538 policy->user_policy.policy = policy->policy; ··· 1092 1094 * Caller should already have policy_rwsem in write mode for this CPU. 1093 1095 * This routine frees the rwsem before returning. 1094 1096 */ 1095 - static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) 1097 + static int __cpufreq_remove_dev(struct device *dev, 1098 + struct subsys_interface *sif) 1096 1099 { 1097 1100 unsigned int cpu = dev->id, ret, cpus; 1098 1101 unsigned long flags; ··· 1200 1201 return 0; 1201 1202 } 1202 1203 1203 - 1204 1204 static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) 1205 1205 { 1206 1206 unsigned int cpu = dev->id; ··· 1212 1214 return retval; 1213 1215 } 1214 1216 1215 - 1216 1217 static void handle_update(struct work_struct *work) 1217 1218 { 1218 1219 struct cpufreq_policy *policy = ··· 1222 1225 } 1223 1226 1224 1227 /** 1225 - * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're in deep trouble. 1228 + * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're 1229 + * in deep trouble. 1226 1230 * @cpu: cpu number 1227 1231 * @old_freq: CPU frequency the kernel thinks the CPU runs at 1228 1232 * @new_freq: CPU frequency the CPU actually runs at ··· 1238 1240 struct cpufreq_freqs freqs; 1239 1241 unsigned long flags; 1240 1242 1241 - 1242 1243 pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " 1243 1244 "core thinks of %u, is %u kHz.\n", old_freq, new_freq); 1244 1245 ··· 1251 1254 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); 1252 1255 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); 1253 1256 } 1254 - 1255 1257 1256 1258 /** 1257 1259 * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur ··· 1296 1300 return ret_freq; 1297 1301 } 1298 1302 EXPORT_SYMBOL(cpufreq_quick_get_max); 1299 - 1300 1303 1301 1304 static unsigned int __cpufreq_get(unsigned int cpu) 1302 1305 { ··· 1354 1359 .add_dev = cpufreq_add_dev, 1355 1360 .remove_dev = cpufreq_remove_dev, 1356 1361 }; 1357 - 1358 1362 1359 1363 /** 1360 1364 * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. ··· 1491 1497 } 1492 1498 EXPORT_SYMBOL(cpufreq_register_notifier); 1493 1499 1494 - 1495 1500 /** 1496 1501 * cpufreq_unregister_notifier - unregister a driver with cpufreq 1497 1502 * @nb: notifier block to be unregistered 1498 - * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER 1503 + * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER 1499 1504 * 1500 1505 * Remove a driver from the CPU frequency notifier list. 1501 1506 * ··· 1529 1536 /********************************************************************* 1530 1537 * GOVERNORS * 1531 1538 *********************************************************************/ 1532 - 1533 1539 1534 1540 int __cpufreq_driver_target(struct cpufreq_policy *policy, 1535 1541 unsigned int target_freq, ··· 1670 1678 return ret; 1671 1679 } 1672 1680 1673 - 1674 1681 int cpufreq_register_governor(struct cpufreq_governor *governor) 1675 1682 { 1676 1683 int err; ··· 1693 1702 return err; 1694 1703 } 1695 1704 EXPORT_SYMBOL_GPL(cpufreq_register_governor); 1696 - 1697 1705 1698 1706 void cpufreq_unregister_governor(struct cpufreq_governor *governor) 1699 1707 { ··· 1723 1733 EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); 1724 1734 1725 1735 1726 - 1727 1736 /********************************************************************* 1728 1737 * POLICY INTERFACE * 1729 1738 *********************************************************************/ ··· 1750 1761 return 0; 1751 1762 } 1752 1763 EXPORT_SYMBOL(cpufreq_get_policy); 1753 - 1754 1764 1755 1765 /* 1756 1766 * data : current policy. ··· 1784 1796 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 1785 1797 CPUFREQ_INCOMPATIBLE, policy); 1786 1798 1787 - /* verify the cpu speed can be set within this limit, 1788 - which might be different to the first one */ 1799 + /* 1800 + * verify the cpu speed can be set within this limit, which might be 1801 + * different to the first one 1802 + */ 1789 1803 ret = cpufreq_driver->verify(policy); 1790 1804 if (ret) 1791 1805 goto error_out; ··· 1889 1899 policy.policy = data->user_policy.policy; 1890 1900 policy.governor = data->user_policy.governor; 1891 1901 1892 - /* BIOS might change freq behind our back 1893 - -> ask driver for current freq and notify governors about a change */ 1902 + /* 1903 + * BIOS might change freq behind our back 1904 + * -> ask driver for current freq and notify governors about a change 1905 + */ 1894 1906 if (cpufreq_driver->get) { 1895 1907 policy.cur = cpufreq_driver->get(cpu); 1896 1908 if (!data->cur) { ··· 1941 1949 } 1942 1950 1943 1951 static struct notifier_block __refdata cpufreq_cpu_notifier = { 1944 - .notifier_call = cpufreq_cpu_callback, 1952 + .notifier_call = cpufreq_cpu_callback, 1945 1953 }; 1946 1954 1947 1955 /********************************************************************* ··· 1953 1961 * @driver_data: A struct cpufreq_driver containing the values# 1954 1962 * submitted by the CPU Frequency driver. 1955 1963 * 1956 - * Registers a CPU Frequency driver to this core code. This code 1964 + * Registers a CPU Frequency driver to this core code. This code 1957 1965 * returns zero on success, -EBUSY when another driver got here first 1958 1966 * (and isn't unregistered in the meantime). 1959 1967 * ··· 2020 2028 } 2021 2029 EXPORT_SYMBOL_GPL(cpufreq_register_driver); 2022 2030 2023 - 2024 2031 /** 2025 2032 * cpufreq_unregister_driver - unregister the current CPUFreq driver 2026 2033 * 2027 - * Unregister the current CPUFreq driver. Only call this if you have 2034 + * Unregister the current CPUFreq driver. Only call this if you have 2028 2035 * the right to do so, i.e. if you have succeeded in initialising before! 2029 2036 * Returns zero if successful, and -EINVAL if the cpufreq_driver is 2030 2037 * currently not initialised.
+2 -2
drivers/cpufreq/cpufreq_governor.h
··· 81 81 return sprintf(buf, "%u\n", tuners->file_name); \ 82 82 } \ 83 83 \ 84 - static ssize_t show_##file_name##_gov_pol \ 84 + static ssize_t show_##file_name##_gov_pol \ 85 85 (struct cpufreq_policy *policy, char *buf) \ 86 86 { \ 87 87 struct dbs_data *dbs_data = policy->governor_data; \ ··· 91 91 92 92 #define store_one(_gov, file_name) \ 93 93 static ssize_t store_##file_name##_gov_sys \ 94 - (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ 94 + (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ 95 95 { \ 96 96 struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ 97 97 return store_##file_name(dbs_data, buf, count); \
-4
drivers/cpufreq/cpufreq_performance.c
··· 17 17 #include <linux/cpufreq.h> 18 18 #include <linux/init.h> 19 19 20 - 21 20 static int cpufreq_governor_performance(struct cpufreq_policy *policy, 22 21 unsigned int event) 23 22 { ··· 43 44 .owner = THIS_MODULE, 44 45 }; 45 46 46 - 47 47 static int __init cpufreq_gov_performance_init(void) 48 48 { 49 49 return cpufreq_register_governor(&cpufreq_gov_performance); 50 50 } 51 51 52 - 53 52 static void __exit cpufreq_gov_performance_exit(void) 54 53 { 55 54 cpufreq_unregister_governor(&cpufreq_gov_performance); 56 55 } 57 - 58 56 59 57 MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); 60 58 MODULE_DESCRIPTION("CPUfreq policy governor 'performance'");
+2 -4
drivers/cpufreq/cpufreq_powersave.c
··· 1 1 /* 2 - * linux/drivers/cpufreq/cpufreq_powersave.c 2 + * linux/drivers/cpufreq/cpufreq_powersave.c 3 3 * 4 - * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 4 + * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 5 5 * 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify ··· 48 48 return cpufreq_register_governor(&cpufreq_gov_powersave); 49 49 } 50 50 51 - 52 51 static void __exit cpufreq_gov_powersave_exit(void) 53 52 { 54 53 cpufreq_unregister_governor(&cpufreq_gov_powersave); 55 54 } 56 - 57 55 58 56 MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); 59 57 MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'");
+2 -2
drivers/cpufreq/cpufreq_stats.c
··· 27 27 struct cpufreq_stats { 28 28 unsigned int cpu; 29 29 unsigned int total_trans; 30 - unsigned long long last_time; 30 + unsigned long long last_time; 31 31 unsigned int max_state; 32 32 unsigned int state_num; 33 33 unsigned int last_index; ··· 116 116 len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", 117 117 stat->freq_table[i]); 118 118 119 - for (j = 0; j < stat->state_num; j++) { 119 + for (j = 0; j < stat->state_num; j++) { 120 120 if (len >= PAGE_SIZE) 121 121 break; 122 122 len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
-4
drivers/cpufreq/cpufreq_userspace.c
··· 55 55 return ret; 56 56 } 57 57 58 - 59 58 static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) 60 59 { 61 60 return sprintf(buf, "%u\n", policy->cur); ··· 100 101 return rc; 101 102 } 102 103 103 - 104 104 #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE 105 105 static 106 106 #endif ··· 116 118 return cpufreq_register_governor(&cpufreq_gov_userspace); 117 119 } 118 120 119 - 120 121 static void __exit cpufreq_gov_userspace_exit(void) 121 122 { 122 123 cpufreq_unregister_governor(&cpufreq_gov_userspace); 123 124 } 124 - 125 125 126 126 MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, " 127 127 "Russell King <rmk@arm.linux.org.uk>");
+20 -21
include/linux/cpufreq.h
··· 1 1 /* 2 - * linux/include/linux/cpufreq.h 2 + * linux/include/linux/cpufreq.h 3 3 * 4 - * Copyright (C) 2001 Russell King 5 - * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 4 + * Copyright (C) 2001 Russell King 5 + * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify 8 8 * it under the terms of the GNU General Public License version 2 as ··· 25 25 #define CPUFREQ_NAME_LEN 16 26 26 /* Print length for names. Extra 1 space for accomodating '\n' in prints */ 27 27 #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) 28 - 29 28 30 29 /********************************************************************* 31 30 * CPUFREQ NOTIFIER INTERFACE * ··· 152 153 u8 flags; /* flags of cpufreq_driver, see below. */ 153 154 }; 154 155 155 - 156 156 /** 157 - * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe) 157 + * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch 158 + * safe) 158 159 * @old: old value 159 160 * @div: divisor 160 161 * @mult: multiplier 161 162 * 162 163 * 163 - * new = old * mult / div 164 + * new = old * mult / div 164 165 */ 165 - static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult) 166 + static inline unsigned long cpufreq_scale(unsigned long old, u_int div, 167 + u_int mult) 166 168 { 167 169 #if BITS_PER_LONG == 32 168 170 ··· 216 216 unsigned int target_freq, 217 217 unsigned int relation); 218 218 219 - 220 219 extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, 221 220 unsigned int cpu); 222 221 223 222 int cpufreq_register_governor(struct cpufreq_governor *governor); 224 223 void cpufreq_unregister_governor(struct cpufreq_governor *governor); 225 - 226 224 227 225 /********************************************************************* 228 226 * CPUFREQ DRIVER INTERFACE * ··· 232 234 struct freq_attr; 233 235 234 236 struct cpufreq_driver { 235 - struct module *owner; 237 + struct module *owner; 236 238 char name[CPUFREQ_NAME_LEN]; 237 239 u8 flags; 238 240 /* ··· 280 282 int cpufreq_register_driver(struct cpufreq_driver *driver_data); 281 283 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); 282 284 283 - 284 285 void cpufreq_notify_transition(struct cpufreq_policy *policy, 285 286 struct cpufreq_freqs *freqs, unsigned int state); 286 287 287 - static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) 288 + static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, 289 + unsigned int min, unsigned int max) 288 290 { 289 291 if (policy->min < min) 290 292 policy->min = min; ··· 347 349 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); 348 350 349 351 #ifdef CONFIG_CPU_FREQ 350 - /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ 352 + /* 353 + * query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it 354 + */ 351 355 unsigned int cpufreq_get(unsigned int cpu); 352 356 #else 353 357 static inline unsigned int cpufreq_get(unsigned int cpu) ··· 358 358 } 359 359 #endif 360 360 361 - /* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it */ 361 + /* 362 + * query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it 363 + */ 362 364 #ifdef CONFIG_CPU_FREQ 363 365 unsigned int cpufreq_quick_get(unsigned int cpu); 364 366 unsigned int cpufreq_quick_get_max(unsigned int cpu); ··· 375 373 } 376 374 #endif 377 375 378 - 379 376 /********************************************************************* 380 377 * CPUFREQ DEFAULT GOVERNOR * 381 378 *********************************************************************/ 382 379 383 - 384 380 /* 385 - Performance governor is fallback governor if any other gov failed to 386 - auto load due latency restrictions 387 - */ 381 + * Performance governor is fallback governor if any other gov failed to auto 382 + * load due latency restrictions 383 + */ 388 384 #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE 389 385 extern struct cpufreq_governor cpufreq_gov_performance; 390 386 #endif ··· 401 401 extern struct cpufreq_governor cpufreq_gov_conservative; 402 402 #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) 403 403 #endif 404 - 405 404 406 405 /********************************************************************* 407 406 * FREQUENCY TABLE HELPERS *