History

cpufreq: Move the IS_ENABLED(CPU_THERMAL) macro into a stub

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.

Daniel Lezcano committed 7 years ago

Commit bcc61561 parent fba74022 files · +8 −4Browse files

Unified · Split

2 files
  1. drivers/cpufreq/cpufreq.c +2 −4
  2. include/linux/cpufreq.h +6 −0
drivers/cpufreq/cpufreq.c+2−4
@@ -1378,8 +1378,7 @@ static int cpufreq_online(unsigned int cpu) · 1377 unmodified lines
13781378 if (cpufreq_driver->ready)
13791379 cpufreq_driver->ready(policy);
13801380
1381− if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
1382− cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
1381+ if (cpufreq_thermal_control_enabled(cpufreq_driver))
13831382 policy->cdev = of_cpufreq_cooling_register(policy);
13841383
13851384 pr_debug("initialization complete\n");
@@ -1469,8 +1468,7 @@ static int cpufreq_offline(unsigned int cpu) · 83 unmodified lines
14691468 goto unlock;
14701469 }
14711470
1472− if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
1473− cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) {
1471+ if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
14741472 cpufreq_cooling_unregister(policy->cdev);
14751473 policy->cdev = NULL;
14761474 }
include/linux/cpufreq.h+6−0
@@ -409,6 +409,12 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); · 408 unmodified lines
409409 const char *cpufreq_get_current_driver(void);
410410 void *cpufreq_get_driver_data(void);
411411
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+
412418 static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
413419 unsigned int min, unsigned int max)
414420 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t