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

Merge branch 'cpu_cooling-doc-comments-update' of .git into next

Zhang Rui 8f578bfe 09681dfa

+37 -29
+29 -21
drivers/thermal/cpu_cooling.c
··· 64 64 * get_idr - function to get a unique id. 65 65 * @idr: struct idr * handle used to create a id. 66 66 * @id: int * value generated by this function. 67 + * 68 + * This function will populate @id with an unique 69 + * id, using the idr API. 70 + * 71 + * Return: 0 on success, an error code on failure. 67 72 */ 68 73 static int get_idr(struct idr *idr, int *id) 69 74 { ··· 80 75 if (unlikely(ret < 0)) 81 76 return ret; 82 77 *id = ret; 78 + 83 79 return 0; 84 80 } 85 81 ··· 111 105 static int is_cpufreq_valid(int cpu) 112 106 { 113 107 struct cpufreq_policy policy; 108 + 114 109 return !cpufreq_get_policy(&policy, cpu); 115 110 } 116 111 ··· 141 134 * Return: 0 on success, -EINVAL when invalid parameters are passed. 142 135 */ 143 136 static int get_property(unsigned int cpu, unsigned long input, 144 - unsigned int* output, enum cpufreq_cooling_property property) 137 + unsigned int *output, 138 + enum cpufreq_cooling_property property) 145 139 { 146 140 int i, j; 147 141 unsigned long max_level = 0, level = 0; ··· 150 142 int descend = -1; 151 143 struct cpufreq_frequency_table *table = 152 144 cpufreq_frequency_get_table(cpu); 153 - 145 + 154 146 if (!output) 155 147 return -EINVAL; 156 148 157 149 if (!table) 158 150 return -EINVAL; 159 151 160 - 161 152 for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { 162 153 /* ignore invalid entries */ 163 154 if (table[i].frequency == CPUFREQ_ENTRY_INVALID) ··· 181 174 } 182 175 183 176 if (property == GET_FREQ) 184 - level = descend ? input : (max_level - input -1); 185 - 177 + level = descend ? input : (max_level - input - 1); 186 178 187 179 for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { 188 180 /* ignore invalid entry */ ··· 207 201 } 208 202 j++; 209 203 } 204 + 210 205 return -EINVAL; 211 206 } 212 207 ··· 228 221 229 222 if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) 230 223 return THERMAL_CSTATE_INVALID; 224 + 231 225 return (unsigned long)val; 232 226 } 233 227 EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); ··· 253 245 ret = get_property(cpu, level, &freq, GET_FREQ); 254 246 if (ret) 255 247 return 0; 248 + 256 249 return freq; 257 250 } 258 251 ··· 270 261 * cooling state). 271 262 */ 272 263 static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, 273 - unsigned long cooling_state) 264 + unsigned long cooling_state) 274 265 { 275 266 unsigned int cpuid, clip_freq; 276 267 struct cpumask *mask = &cpufreq_device->allowed_cpus; ··· 312 303 * Return: 0 (success) 313 304 */ 314 305 static int cpufreq_thermal_notifier(struct notifier_block *nb, 315 - unsigned long event, void *data) 306 + unsigned long event, void *data) 316 307 { 317 308 struct cpufreq_policy *policy = data; 318 309 unsigned long max_freq = 0; ··· 323 314 if (cpumask_test_cpu(policy->cpu, &notify_device->allowed_cpus)) 324 315 max_freq = notify_device->cpufreq_val; 325 316 326 - /* Never exceed user_policy.max*/ 317 + /* Never exceed user_policy.max */ 327 318 if (max_freq > policy->user_policy.max) 328 319 max_freq = policy->user_policy.max; 329 320 ··· 333 324 return 0; 334 325 } 335 326 336 - /* 337 - * cpufreq cooling device callback functions are defined below 338 - */ 327 + /* cpufreq cooling device callback functions are defined below */ 339 328 340 329 /** 341 330 * cpufreq_get_max_state - callback function to get the max cooling state. ··· 380 373 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; 381 374 382 375 *state = cpufreq_device->cpufreq_state; 376 + 383 377 return 0; 384 378 } 385 379 ··· 425 417 * Return: a valid struct thermal_cooling_device pointer on success, 426 418 * on failure, it returns a corresponding ERR_PTR(). 427 419 */ 428 - struct thermal_cooling_device *cpufreq_cooling_register( 429 - const struct cpumask *clip_cpus) 420 + struct thermal_cooling_device * 421 + cpufreq_cooling_register(const struct cpumask *clip_cpus) 430 422 { 431 423 struct thermal_cooling_device *cool_dev; 432 424 struct cpufreq_cooling_device *cpufreq_dev = NULL; ··· 435 427 int ret = 0, i; 436 428 struct cpufreq_policy policy; 437 429 438 - /*Verify that all the clip cpus have same freq_min, freq_max limit*/ 430 + /* Verify that all the clip cpus have same freq_min, freq_max limit */ 439 431 for_each_cpu(i, clip_cpus) { 440 - /*continue if cpufreq policy not found and not return error*/ 432 + /* continue if cpufreq policy not found and not return error */ 441 433 if (!cpufreq_get_policy(&policy, i)) 442 434 continue; 443 435 if (min == 0 && max == 0) { ··· 445 437 max = policy.cpuinfo.max_freq; 446 438 } else { 447 439 if (min != policy.cpuinfo.min_freq || 448 - max != policy.cpuinfo.max_freq) 440 + max != policy.cpuinfo.max_freq) 449 441 return ERR_PTR(-EINVAL); 450 442 } 451 443 } 452 444 cpufreq_dev = kzalloc(sizeof(struct cpufreq_cooling_device), 453 - GFP_KERNEL); 445 + GFP_KERNEL); 454 446 if (!cpufreq_dev) 455 447 return ERR_PTR(-ENOMEM); 456 448 ··· 466 458 cpufreq_dev->id); 467 459 468 460 cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev, 469 - &cpufreq_cooling_ops); 461 + &cpufreq_cooling_ops); 470 462 if (!cool_dev) { 471 463 release_idr(&cpufreq_idr, cpufreq_dev->id); 472 464 kfree(cpufreq_dev); ··· 479 471 /* Register the notifier for first cpufreq cooling device */ 480 472 if (cpufreq_dev_count == 0) 481 473 cpufreq_register_notifier(&thermal_cpufreq_notifier_block, 482 - CPUFREQ_POLICY_NOTIFIER); 474 + CPUFREQ_POLICY_NOTIFIER); 483 475 cpufreq_dev_count++; 484 476 485 477 mutex_unlock(&cooling_cpufreq_lock); 478 + 486 479 return cool_dev; 487 480 } 488 481 EXPORT_SYMBOL_GPL(cpufreq_cooling_register); ··· 504 495 /* Unregister the notifier for the last cpufreq cooling device */ 505 496 if (cpufreq_dev_count == 0) 506 497 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, 507 - CPUFREQ_POLICY_NOTIFIER); 508 - 498 + CPUFREQ_POLICY_NOTIFIER); 509 499 mutex_unlock(&cooling_cpufreq_lock); 510 500 511 501 thermal_cooling_device_unregister(cpufreq_dev->cool_dev);
+8 -8
include/linux/cpu_cooling.h
··· 32 32 * cpufreq_cooling_register - function to create cpufreq cooling device. 33 33 * @clip_cpus: cpumask of cpus where the frequency constraints will happen 34 34 */ 35 - struct thermal_cooling_device *cpufreq_cooling_register( 36 - const struct cpumask *clip_cpus); 35 + struct thermal_cooling_device * 36 + cpufreq_cooling_register(const struct cpumask *clip_cpus); 37 37 38 38 /** 39 39 * cpufreq_cooling_unregister - function to remove cpufreq cooling device. ··· 43 43 44 44 unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int); 45 45 #else /* !CONFIG_CPU_THERMAL */ 46 - static inline struct thermal_cooling_device *cpufreq_cooling_register( 47 - const struct cpumask *clip_cpus) 46 + static inline struct thermal_cooling_device * 47 + cpufreq_cooling_register(const struct cpumask *clip_cpus) 48 48 { 49 49 return NULL; 50 50 } 51 - static inline void cpufreq_cooling_unregister( 52 - struct thermal_cooling_device *cdev) 51 + static inline 52 + void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) 53 53 { 54 54 return; 55 55 } 56 - static inline unsigned long cpufreq_cooling_get_level(unsigned int, 57 - unsigned int) 56 + static inline 57 + unsigned long cpufreq_cooling_get_level(unsigned int, unsigned int) 58 58 { 59 59 return THERMAL_CSTATE_INVALID; 60 60 }