Skip to content

Commit 077f235

Browse files
committed
cpufreq/amd-pstate: Add static asserts for EPP indices
In case a new index is introduced add a static assert to make sure that strings and values are updated. Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
1 parent e9d62ca commit 077f235

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/cpufreq/amd-pstate.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ enum energy_perf_value_index {
110110
EPP_INDEX_BALANCE_PERFORMANCE,
111111
EPP_INDEX_BALANCE_POWERSAVE,
112112
EPP_INDEX_POWERSAVE,
113+
EPP_INDEX_MAX,
113114
};
114115

115116
static const char * const energy_perf_strings[] = {
@@ -119,6 +120,7 @@ static const char * const energy_perf_strings[] = {
119120
[EPP_INDEX_BALANCE_POWERSAVE] = "balance_power",
120121
[EPP_INDEX_POWERSAVE] = "power",
121122
};
123+
static_assert(ARRAY_SIZE(energy_perf_strings) == EPP_INDEX_MAX);
122124

123125
static unsigned int epp_values[] = {
124126
[EPP_INDEX_DEFAULT] = 0,
@@ -127,6 +129,7 @@ static unsigned int epp_values[] = {
127129
[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE,
128130
[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE,
129131
};
132+
static_assert(ARRAY_SIZE(epp_values) == EPP_INDEX_MAX);
130133

131134
typedef int (*cppc_mode_transition_fn)(int);
132135

0 commit comments

Comments
 (0)