The structs representing capacity states and performance domains of an Energy Model are currently only defined for CONFIG_ENERGY_MODEL=y. That makes it hard for code outside PM_EM to manipulate those structures without a lot of ifdefery or stubbed accessors. So, move the declaration of the two structs outside of the CONFIG_ENERGY_MODEL ifdef. The client code (e.g. EAS or thermal) always checks the return of em_cpu_get() before using it, so the exising code is still safe to use as-is.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -9,7 +9,6 @@ · 8 unmodified lines | |||
| 9 | #include <linux/sched/topology.h> | 9 | #include <linux/sched/topology.h> |
| 10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
| 11 | 11 | ||
| 12 | #ifdef CONFIG_ENERGY_MODEL | ||
| 13 | /** | 12 | /** |
| 14 | * em_cap_state - Capacity state of a performance domain | 13 | * em_cap_state - Capacity state of a performance domain |
| 15 | * @frequency: The CPU frequency in KHz, for consistency with CPUFreq | 14 | * @frequency: The CPU frequency in KHz, for consistency with CPUFreq |
| @@ -40,6 +39,7 @@ struct em_perf_domain { · 24 unmodified lines | |||
| 40 | unsigned long cpus[0]; | 39 | unsigned long cpus[0]; |
| 41 | }; | 40 | }; |
| 42 | 41 | ||
| 42 | #ifdef CONFIG_ENERGY_MODEL | ||
| 43 | #define EM_CPU_MAX_POWER 0xFFFF | 43 | #define EM_CPU_MAX_POWER 0xFFFF |
| 44 | 44 | ||
| 45 | struct em_data_callback { | 45 | struct em_data_callback { |
| @@ -160,7 +160,6 @@ static inline int em_pd_nr_cap_states(struct em_perf_domain *pd) · 114 unmodified lines | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | #else | 162 | #else |
| 163 | struct em_perf_domain {}; | ||
| 164 | struct em_data_callback {}; | 163 | struct em_data_callback {}; |
| 165 | #define EM_DATA_CB(_active_power_cb) { } | 164 | #define EM_DATA_CB(_active_power_cb) { } |
| 166 | 165 | ||