cpufreq_online() and cpufreq_offline() [un]register the driver as a cooling device. This is done if the driver is flagged as a cooling device in addition with an IS_ENABLED() check to compile out the branching code. Group this test in a stub function added in the cpufreq header instead of having the IS_ENABLED() in the code.
Unified · Split
| @@ -1378,8 +1378,7 @@ static int cpufreq_online(unsigned int cpu) · 1377 unmodified lines | |||
| 1378 | if (cpufreq_driver->ready) | 1378 | if (cpufreq_driver->ready) |
| 1379 | cpufreq_driver->ready(policy); | 1379 | cpufreq_driver->ready(policy); |
| 1380 | 1380 | ||
| 1381 | if (IS_ENABLED(CONFIG_CPU_THERMAL) && | 1381 | if (cpufreq_thermal_control_enabled(cpufreq_driver)) |
| 1382 | cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) | ||
| 1383 | policy->cdev = of_cpufreq_cooling_register(policy); | 1382 | policy->cdev = of_cpufreq_cooling_register(policy); |
| 1384 | 1383 | ||
| 1385 | pr_debug("initialization complete\n"); | 1384 | pr_debug("initialization complete\n"); |
| @@ -1469,8 +1468,7 @@ static int cpufreq_offline(unsigned int cpu) · 83 unmodified lines | |||
| 1469 | goto unlock; | 1468 | goto unlock; |
| 1470 | } | 1469 | } |
| 1471 | 1470 | ||
| 1472 | if (IS_ENABLED(CONFIG_CPU_THERMAL) && | 1471 | if (cpufreq_thermal_control_enabled(cpufreq_driver)) { |
| 1473 | cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) { | ||
| 1474 | cpufreq_cooling_unregister(policy->cdev); | 1472 | cpufreq_cooling_unregister(policy->cdev); |
| 1475 | policy->cdev = NULL; | 1473 | policy->cdev = NULL; |
| 1476 | } | 1474 | } |
| @@ -409,6 +409,12 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); · 408 unmodified lines | |||
| 409 | const char *cpufreq_get_current_driver(void); | 409 | const char *cpufreq_get_current_driver(void); |
| 410 | void *cpufreq_get_driver_data(void); | 410 | void *cpufreq_get_driver_data(void); |
| 411 | 411 | ||
| 412 | static inline int cpufreq_thermal_control_enabled(struct cpufreq_driver *drv) | ||
| 413 | { | ||
| 414 | return IS_ENABLED(CONFIG_CPU_THERMAL) && | ||
| 415 | (drv->flags & CPUFREQ_IS_COOLING_DEV); | ||
| 416 | } | ||
| 417 | |||
| 412 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, | 418 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, |
| 413 | unsigned int min, unsigned int max) | 419 | unsigned int min, unsigned int max) |
| 414 | { | 420 | { |